mpi3mr_os.c (c87866ede44ad7da6b296d732221dc34ce1b154d) | mpi3mr_os.c (0da66348c26ffde19d69ed7770514d202afde222) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Driver for Broadcom MPI3 Storage Controllers 4 * 5 * Copyright (C) 2017-2021 Broadcom Inc. 6 * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com) 7 * 8 */ --- 36 unchanged lines hidden (view full) --- 45 */ 46static u16 mpi3mr_host_tag_for_scmd(struct mpi3mr_ioc *mrioc, 47 struct scsi_cmnd *scmd) 48{ 49 struct scmd_priv *priv = NULL; 50 u32 unique_tag; 51 u16 host_tag, hw_queue; 52 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Driver for Broadcom MPI3 Storage Controllers 4 * 5 * Copyright (C) 2017-2021 Broadcom Inc. 6 * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com) 7 * 8 */ --- 36 unchanged lines hidden (view full) --- 45 */ 46static u16 mpi3mr_host_tag_for_scmd(struct mpi3mr_ioc *mrioc, 47 struct scsi_cmnd *scmd) 48{ 49 struct scmd_priv *priv = NULL; 50 u32 unique_tag; 51 u16 host_tag, hw_queue; 52 |
53 unique_tag = blk_mq_unique_tag(scmd->request); | 53 unique_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd)); |
54 55 hw_queue = blk_mq_unique_tag_to_hwq(unique_tag); 56 if (hw_queue >= mrioc->num_op_reply_q) 57 return MPI3MR_HOSTTAG_INVALID; 58 host_tag = blk_mq_unique_tag_to_tag(unique_tag); 59 60 if (WARN_ON(host_tag >= mrioc->max_host_ios)) 61 return MPI3MR_HOSTTAG_INVALID; --- 1896 unchanged lines hidden (view full) --- 1958 * 1959 * Return: Nothing 1960 */ 1961static void mpi3mr_setup_eedp(struct mpi3mr_ioc *mrioc, 1962 struct scsi_cmnd *scmd, struct mpi3_scsi_io_request *scsiio_req) 1963{ 1964 u16 eedp_flags = 0; 1965 unsigned char prot_op = scsi_get_prot_op(scmd); | 54 55 hw_queue = blk_mq_unique_tag_to_hwq(unique_tag); 56 if (hw_queue >= mrioc->num_op_reply_q) 57 return MPI3MR_HOSTTAG_INVALID; 58 host_tag = blk_mq_unique_tag_to_tag(unique_tag); 59 60 if (WARN_ON(host_tag >= mrioc->max_host_ios)) 61 return MPI3MR_HOSTTAG_INVALID; --- 1896 unchanged lines hidden (view full) --- 1958 * 1959 * Return: Nothing 1960 */ 1961static void mpi3mr_setup_eedp(struct mpi3mr_ioc *mrioc, 1962 struct scsi_cmnd *scmd, struct mpi3_scsi_io_request *scsiio_req) 1963{ 1964 u16 eedp_flags = 0; 1965 unsigned char prot_op = scsi_get_prot_op(scmd); |
1966 unsigned char prot_type = scsi_get_prot_type(scmd); | |
1967 1968 switch (prot_op) { 1969 case SCSI_PROT_NORMAL: 1970 return; 1971 case SCSI_PROT_READ_STRIP: 1972 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK_REMOVE; 1973 break; 1974 case SCSI_PROT_WRITE_INSERT: 1975 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_INSERT; 1976 break; 1977 case SCSI_PROT_READ_INSERT: 1978 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_INSERT; 1979 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 1980 break; 1981 case SCSI_PROT_WRITE_STRIP: 1982 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK_REMOVE; 1983 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 1984 break; 1985 case SCSI_PROT_READ_PASS: | 1966 1967 switch (prot_op) { 1968 case SCSI_PROT_NORMAL: 1969 return; 1970 case SCSI_PROT_READ_STRIP: 1971 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK_REMOVE; 1972 break; 1973 case SCSI_PROT_WRITE_INSERT: 1974 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_INSERT; 1975 break; 1976 case SCSI_PROT_READ_INSERT: 1977 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_INSERT; 1978 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 1979 break; 1980 case SCSI_PROT_WRITE_STRIP: 1981 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK_REMOVE; 1982 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 1983 break; 1984 case SCSI_PROT_READ_PASS: |
1986 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK | 1987 MPI3_EEDPFLAGS_CHK_REF_TAG | MPI3_EEDPFLAGS_CHK_APP_TAG | 1988 MPI3_EEDPFLAGS_CHK_GUARD; | 1985 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK; |
1989 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 1990 break; 1991 case SCSI_PROT_WRITE_PASS: | 1986 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 1987 break; 1988 case SCSI_PROT_WRITE_PASS: |
1992 if (scsi_host_get_guard(scmd->device->host) 1993 & SHOST_DIX_GUARD_IP) { 1994 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK_REGEN | 1995 MPI3_EEDPFLAGS_CHK_APP_TAG | 1996 MPI3_EEDPFLAGS_CHK_GUARD | 1997 MPI3_EEDPFLAGS_INCR_PRI_REF_TAG; | 1989 if (scmd->prot_flags & SCSI_PROT_IP_CHECKSUM) { 1990 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK_REGEN; |
1998 scsiio_req->sgl[0].eedp.application_tag_translation_mask = 1999 0xffff; | 1991 scsiio_req->sgl[0].eedp.application_tag_translation_mask = 1992 0xffff; |
2000 } else { 2001 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK | 2002 MPI3_EEDPFLAGS_CHK_REF_TAG | 2003 MPI3_EEDPFLAGS_CHK_APP_TAG | 2004 MPI3_EEDPFLAGS_CHK_GUARD; 2005 } | 1993 } else 1994 eedp_flags = MPI3_EEDPFLAGS_EEDP_OP_CHECK; 1995 |
2006 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 2007 break; 2008 default: 2009 return; 2010 } 2011 | 1996 scsiio_req->msg_flags |= MPI3_SCSIIO_MSGFLAGS_METASGL_VALID; 1997 break; 1998 default: 1999 return; 2000 } 2001 |
2012 if (scsi_host_get_guard(scmd->device->host) & SHOST_DIX_GUARD_IP) | 2002 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK) 2003 eedp_flags |= MPI3_EEDPFLAGS_CHK_GUARD; 2004 2005 if (scmd->prot_flags & SCSI_PROT_IP_CHECKSUM) |
2013 eedp_flags |= MPI3_EEDPFLAGS_HOST_GUARD_IP_CHKSUM; 2014 | 2006 eedp_flags |= MPI3_EEDPFLAGS_HOST_GUARD_IP_CHKSUM; 2007 |
2015 switch (prot_type) { 2016 case SCSI_PROT_DIF_TYPE0: 2017 eedp_flags |= MPI3_EEDPFLAGS_INCR_PRI_REF_TAG; | 2008 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) { 2009 eedp_flags |= MPI3_EEDPFLAGS_CHK_REF_TAG | 2010 MPI3_EEDPFLAGS_INCR_PRI_REF_TAG; |
2018 scsiio_req->cdb.eedp32.primary_reference_tag = | 2011 scsiio_req->cdb.eedp32.primary_reference_tag = |
2019 cpu_to_be32(t10_pi_ref_tag(scmd->request)); 2020 break; 2021 case SCSI_PROT_DIF_TYPE1: 2022 case SCSI_PROT_DIF_TYPE2: 2023 eedp_flags |= MPI3_EEDPFLAGS_INCR_PRI_REF_TAG | 2024 MPI3_EEDPFLAGS_ESC_MODE_APPTAG_DISABLE | 2025 MPI3_EEDPFLAGS_CHK_GUARD; 2026 scsiio_req->cdb.eedp32.primary_reference_tag = 2027 cpu_to_be32(t10_pi_ref_tag(scmd->request)); 2028 break; 2029 case SCSI_PROT_DIF_TYPE3: 2030 eedp_flags |= MPI3_EEDPFLAGS_CHK_GUARD | 2031 MPI3_EEDPFLAGS_ESC_MODE_APPTAG_DISABLE; 2032 break; 2033 2034 default: 2035 scsiio_req->msg_flags &= ~(MPI3_SCSIIO_MSGFLAGS_METASGL_VALID); 2036 return; | 2012 cpu_to_be32(scsi_prot_ref_tag(scmd)); |
2037 } 2038 | 2013 } 2014 |
2039 switch (scmd->device->sector_size) { | 2015 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) 2016 eedp_flags |= MPI3_EEDPFLAGS_INCR_PRI_REF_TAG; 2017 2018 eedp_flags |= MPI3_EEDPFLAGS_ESC_MODE_APPTAG_DISABLE; 2019 2020 switch (scsi_prot_interval(scmd)) { |
2040 case 512: 2041 scsiio_req->sgl[0].eedp.user_data_size = MPI3_EEDP_UDS_512; 2042 break; 2043 case 520: 2044 scsiio_req->sgl[0].eedp.user_data_size = MPI3_EEDP_UDS_520; 2045 break; 2046 case 4080: 2047 scsiio_req->sgl[0].eedp.user_data_size = MPI3_EEDP_UDS_4080; --- 1398 unchanged lines hidden (view full) --- 3446 struct mpi3mr_sdev_priv_data *sdev_priv_data; 3447 struct scmd_priv *scmd_priv_data = NULL; 3448 struct mpi3_scsi_io_request *scsiio_req = NULL; 3449 struct op_req_qinfo *op_req_q = NULL; 3450 int retval = 0; 3451 u16 dev_handle; 3452 u16 host_tag; 3453 u32 scsiio_flags = 0; | 2021 case 512: 2022 scsiio_req->sgl[0].eedp.user_data_size = MPI3_EEDP_UDS_512; 2023 break; 2024 case 520: 2025 scsiio_req->sgl[0].eedp.user_data_size = MPI3_EEDP_UDS_520; 2026 break; 2027 case 4080: 2028 scsiio_req->sgl[0].eedp.user_data_size = MPI3_EEDP_UDS_4080; --- 1398 unchanged lines hidden (view full) --- 3427 struct mpi3mr_sdev_priv_data *sdev_priv_data; 3428 struct scmd_priv *scmd_priv_data = NULL; 3429 struct mpi3_scsi_io_request *scsiio_req = NULL; 3430 struct op_req_qinfo *op_req_q = NULL; 3431 int retval = 0; 3432 u16 dev_handle; 3433 u16 host_tag; 3434 u32 scsiio_flags = 0; |
3454 struct request *rq = scmd->request; | 3435 struct request *rq = scsi_cmd_to_rq(scmd); |
3455 int iprio_class; 3456 3457 sdev_priv_data = scmd->device->hostdata; 3458 if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) { 3459 scmd->result = DID_NO_CONNECT << 16; 3460 scmd->scsi_done(scmd); 3461 goto out; 3462 } --- 327 unchanged lines hidden (view full) --- 3790 if (!mrioc->fwevt_worker_thread) { 3791 ioc_err(mrioc, "failure at %s:%d/%s()!\n", 3792 __FILE__, __LINE__, __func__); 3793 retval = -ENODEV; 3794 goto out_fwevtthread_failed; 3795 } 3796 3797 mrioc->is_driver_loading = 1; | 3436 int iprio_class; 3437 3438 sdev_priv_data = scmd->device->hostdata; 3439 if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) { 3440 scmd->result = DID_NO_CONNECT << 16; 3441 scmd->scsi_done(scmd); 3442 goto out; 3443 } --- 327 unchanged lines hidden (view full) --- 3771 if (!mrioc->fwevt_worker_thread) { 3772 ioc_err(mrioc, "failure at %s:%d/%s()!\n", 3773 __FILE__, __LINE__, __func__); 3774 retval = -ENODEV; 3775 goto out_fwevtthread_failed; 3776 } 3777 3778 mrioc->is_driver_loading = 1; |
3798 if (mpi3mr_init_ioc(mrioc, 0)) { | 3779 if (mpi3mr_init_ioc(mrioc, MPI3MR_IT_INIT)) { |
3799 ioc_err(mrioc, "failure at %s:%d/%s()!\n", 3800 __FILE__, __LINE__, __func__); 3801 retval = -ENODEV; 3802 goto out_iocinit_failed; 3803 } 3804 3805 shost->nr_hw_queues = mrioc->num_op_reply_q; 3806 shost->can_queue = mrioc->max_host_ios; --- 6 unchanged lines hidden (view full) --- 3813 __FILE__, __LINE__, __func__); 3814 goto addhost_failed; 3815 } 3816 3817 scsi_scan_host(shost); 3818 return retval; 3819 3820addhost_failed: | 3780 ioc_err(mrioc, "failure at %s:%d/%s()!\n", 3781 __FILE__, __LINE__, __func__); 3782 retval = -ENODEV; 3783 goto out_iocinit_failed; 3784 } 3785 3786 shost->nr_hw_queues = mrioc->num_op_reply_q; 3787 shost->can_queue = mrioc->max_host_ios; --- 6 unchanged lines hidden (view full) --- 3794 __FILE__, __LINE__, __func__); 3795 goto addhost_failed; 3796 } 3797 3798 scsi_scan_host(shost); 3799 return retval; 3800 3801addhost_failed: |
3821 mpi3mr_cleanup_ioc(mrioc, 0); | 3802 mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP); |
3822out_iocinit_failed: 3823 destroy_workqueue(mrioc->fwevt_worker_thread); 3824out_fwevtthread_failed: 3825 spin_lock(&mrioc_list_lock); 3826 list_del(&mrioc->list); 3827 spin_unlock(&mrioc_list_lock); 3828 scsi_host_put(shost); 3829shost_failed: --- 35 unchanged lines hidden (view full) --- 3865 scsi_remove_host(shost); 3866 3867 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list, 3868 list) { 3869 mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev); 3870 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev); 3871 mpi3mr_tgtdev_put(tgtdev); 3872 } | 3803out_iocinit_failed: 3804 destroy_workqueue(mrioc->fwevt_worker_thread); 3805out_fwevtthread_failed: 3806 spin_lock(&mrioc_list_lock); 3807 list_del(&mrioc->list); 3808 spin_unlock(&mrioc_list_lock); 3809 scsi_host_put(shost); 3810shost_failed: --- 35 unchanged lines hidden (view full) --- 3846 scsi_remove_host(shost); 3847 3848 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list, 3849 list) { 3850 mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev); 3851 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev); 3852 mpi3mr_tgtdev_put(tgtdev); 3853 } |
3873 mpi3mr_cleanup_ioc(mrioc, 0); | 3854 mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP); |
3874 3875 spin_lock(&mrioc_list_lock); 3876 list_del(&mrioc->list); 3877 spin_unlock(&mrioc_list_lock); 3878 3879 scsi_host_put(shost); 3880} 3881 --- 23 unchanged lines hidden (view full) --- 3905 mrioc->stop_drv_processing = 1; 3906 mpi3mr_cleanup_fwevt_list(mrioc); 3907 spin_lock_irqsave(&mrioc->fwevt_lock, flags); 3908 wq = mrioc->fwevt_worker_thread; 3909 mrioc->fwevt_worker_thread = NULL; 3910 spin_unlock_irqrestore(&mrioc->fwevt_lock, flags); 3911 if (wq) 3912 destroy_workqueue(wq); | 3855 3856 spin_lock(&mrioc_list_lock); 3857 list_del(&mrioc->list); 3858 spin_unlock(&mrioc_list_lock); 3859 3860 scsi_host_put(shost); 3861} 3862 --- 23 unchanged lines hidden (view full) --- 3886 mrioc->stop_drv_processing = 1; 3887 mpi3mr_cleanup_fwevt_list(mrioc); 3888 spin_lock_irqsave(&mrioc->fwevt_lock, flags); 3889 wq = mrioc->fwevt_worker_thread; 3890 mrioc->fwevt_worker_thread = NULL; 3891 spin_unlock_irqrestore(&mrioc->fwevt_lock, flags); 3892 if (wq) 3893 destroy_workqueue(wq); |
3913 mpi3mr_cleanup_ioc(mrioc, 0); | 3894 mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP); |
3914} 3915 3916#ifdef CONFIG_PM 3917/** 3918 * mpi3mr_suspend - PCI power management suspend callback 3919 * @pdev: PCI device instance 3920 * @state: New power state 3921 * --- 13 unchanged lines hidden (view full) --- 3935 3936 mrioc = shost_priv(shost); 3937 while (mrioc->reset_in_progress || mrioc->is_driver_loading) 3938 ssleep(1); 3939 mrioc->stop_drv_processing = 1; 3940 mpi3mr_cleanup_fwevt_list(mrioc); 3941 scsi_block_requests(shost); 3942 mpi3mr_stop_watchdog(mrioc); | 3895} 3896 3897#ifdef CONFIG_PM 3898/** 3899 * mpi3mr_suspend - PCI power management suspend callback 3900 * @pdev: PCI device instance 3901 * @state: New power state 3902 * --- 13 unchanged lines hidden (view full) --- 3916 3917 mrioc = shost_priv(shost); 3918 while (mrioc->reset_in_progress || mrioc->is_driver_loading) 3919 ssleep(1); 3920 mrioc->stop_drv_processing = 1; 3921 mpi3mr_cleanup_fwevt_list(mrioc); 3922 scsi_block_requests(shost); 3923 mpi3mr_stop_watchdog(mrioc); |
3943 mpi3mr_cleanup_ioc(mrioc, 1); | 3924 mpi3mr_cleanup_ioc(mrioc, MPI3MR_SUSPEND); |
3944 3945 device_state = pci_choose_state(pdev, state); 3946 ioc_info(mrioc, "pdev=0x%p, slot=%s, entering operating state [D%d]\n", 3947 pdev, pci_name(pdev), device_state); 3948 pci_save_state(pdev); 3949 pci_set_power_state(pdev, device_state); 3950 mpi3mr_cleanup_resources(mrioc); 3951 --- 31 unchanged lines hidden (view full) --- 3983 r = mpi3mr_setup_resources(mrioc); 3984 if (r) { 3985 ioc_info(mrioc, "%s: Setup resources failed[%d]\n", 3986 __func__, r); 3987 return r; 3988 } 3989 3990 mrioc->stop_drv_processing = 0; | 3925 3926 device_state = pci_choose_state(pdev, state); 3927 ioc_info(mrioc, "pdev=0x%p, slot=%s, entering operating state [D%d]\n", 3928 pdev, pci_name(pdev), device_state); 3929 pci_save_state(pdev); 3930 pci_set_power_state(pdev, device_state); 3931 mpi3mr_cleanup_resources(mrioc); 3932 --- 31 unchanged lines hidden (view full) --- 3964 r = mpi3mr_setup_resources(mrioc); 3965 if (r) { 3966 ioc_info(mrioc, "%s: Setup resources failed[%d]\n", 3967 __func__, r); 3968 return r; 3969 } 3970 3971 mrioc->stop_drv_processing = 0; |
3991 mpi3mr_init_ioc(mrioc, 1); | 3972 mpi3mr_memset_buffers(mrioc); 3973 mpi3mr_init_ioc(mrioc, MPI3MR_IT_RESUME); |
3992 scsi_unblock_requests(shost); 3993 mpi3mr_start_watchdog(mrioc); 3994 3995 return 0; 3996} 3997#endif 3998 3999static const struct pci_device_id mpi3mr_pci_id_table[] = { --- 47 unchanged lines hidden --- | 3974 scsi_unblock_requests(shost); 3975 mpi3mr_start_watchdog(mrioc); 3976 3977 return 0; 3978} 3979#endif 3980 3981static const struct pci_device_id mpi3mr_pci_id_table[] = { --- 47 unchanged lines hidden --- |