isp_freebsd.c (316402) | isp_freebsd.c (316406) |
---|---|
1/*- 2 * Copyright (c) 1997-2009 by Matthew Jacob 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27/* 28 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters. 29 */ 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2009 by Matthew Jacob 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27/* 28 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters. 29 */ 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: stable/11/sys/dev/isp/isp_freebsd.c 316402 2017-04-02 10:54:28Z mav $"); | 31__FBSDID("$FreeBSD: stable/11/sys/dev/isp/isp_freebsd.c 316406 2017-04-02 10:57:19Z mav $"); |
32 33#include <dev/isp/isp_freebsd.h> 34#include <sys/unistd.h> 35#include <sys/kthread.h> 36#include <sys/conf.h> 37#include <sys/module.h> 38#include <sys/ioccom.h> 39#include <dev/isp/isp_ioctl.h> --- 1196 unchanged lines hidden (view full) --- 1236 cto->ct_header.rqs_seqno |= ATPD_SEQ_NOTIFY_CAM; 1237 ATPD_SET_SEQNO(cto, atp); 1238 cto->ct_nphdl = atp->nphdl; 1239 cto->ct_rxid = atp->tag; 1240 cto->ct_iid_lo = atp->sid; 1241 cto->ct_iid_hi = atp->sid >> 16; 1242 cto->ct_oxid = atp->oxid; 1243 cto->ct_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(ccb)); | 32 33#include <dev/isp/isp_freebsd.h> 34#include <sys/unistd.h> 35#include <sys/kthread.h> 36#include <sys/conf.h> 37#include <sys/module.h> 38#include <sys/ioccom.h> 39#include <dev/isp/isp_ioctl.h> --- 1196 unchanged lines hidden (view full) --- 1236 cto->ct_header.rqs_seqno |= ATPD_SEQ_NOTIFY_CAM; 1237 ATPD_SET_SEQNO(cto, atp); 1238 cto->ct_nphdl = atp->nphdl; 1239 cto->ct_rxid = atp->tag; 1240 cto->ct_iid_lo = atp->sid; 1241 cto->ct_iid_hi = atp->sid >> 16; 1242 cto->ct_oxid = atp->oxid; 1243 cto->ct_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(ccb)); |
1244 cto->ct_timeout = (XS_TIME(ccb) + 999) / 1000; | 1244 cto->ct_timeout = XS_TIME(ccb); |
1245 cto->ct_flags = atp->tattr << CT7_TASK_ATTR_SHIFT; 1246 1247 /* 1248 * Mode 1, status, no data. Only possible when we are sending status, have 1249 * no data to transfer, and any sense data can fit into a ct7_entry_t. 1250 * 1251 * Mode 2, status, no data. We have to use this in the case that 1252 * the sense data won't fit into a ct7_entry_t. --- 132 unchanged lines hidden (view full) --- 1385 if (ISP_CAP_2KLOGIN(isp)) { 1386 ((ct2e_entry_t *)cto)->ct_iid = atp->nphdl; 1387 } else { 1388 cto->ct_iid = atp->nphdl; 1389 if (ISP_CAP_SCCFW(isp) == 0) { 1390 cto->ct_lun = ccb->ccb_h.target_lun; 1391 } 1392 } | 1245 cto->ct_flags = atp->tattr << CT7_TASK_ATTR_SHIFT; 1246 1247 /* 1248 * Mode 1, status, no data. Only possible when we are sending status, have 1249 * no data to transfer, and any sense data can fit into a ct7_entry_t. 1250 * 1251 * Mode 2, status, no data. We have to use this in the case that 1252 * the sense data won't fit into a ct7_entry_t. --- 132 unchanged lines hidden (view full) --- 1385 if (ISP_CAP_2KLOGIN(isp)) { 1386 ((ct2e_entry_t *)cto)->ct_iid = atp->nphdl; 1387 } else { 1388 cto->ct_iid = atp->nphdl; 1389 if (ISP_CAP_SCCFW(isp) == 0) { 1390 cto->ct_lun = ccb->ccb_h.target_lun; 1391 } 1392 } |
1393 cto->ct_timeout = (XS_TIME(ccb) + 999) / 1000; | 1393 cto->ct_timeout = XS_TIME(ccb); |
1394 cto->ct_rxid = cso->tag_id; 1395 1396 /* 1397 * Mode 1, status, no data. Only possible when we are sending status, have 1398 * no data to transfer, and the sense length can fit in the ct7_entry. 1399 * 1400 * Mode 2, status, no data. We have to use this in the case the response 1401 * length won't fit into a ct2_entry_t. --- 1551 unchanged lines hidden (view full) --- 2953 return; 2954 } 2955} 2956#endif 2957 2958static void 2959isp_action(struct cam_sim *sim, union ccb *ccb) 2960{ | 1394 cto->ct_rxid = cso->tag_id; 1395 1396 /* 1397 * Mode 1, status, no data. Only possible when we are sending status, have 1398 * no data to transfer, and the sense length can fit in the ct7_entry. 1399 * 1400 * Mode 2, status, no data. We have to use this in the case the response 1401 * length won't fit into a ct2_entry_t. --- 1551 unchanged lines hidden (view full) --- 2953 return; 2954 } 2955} 2956#endif 2957 2958static void 2959isp_action(struct cam_sim *sim, union ccb *ccb) 2960{ |
2961 int bus, tgt, ts, error; | 2961 int bus, tgt, error; |
2962 ispsoftc_t *isp; 2963 struct ccb_trans_settings *cts; | 2962 ispsoftc_t *isp; 2963 struct ccb_trans_settings *cts; |
2964 sbintime_t ts; |
|
2964 2965 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("isp_action\n")); 2966 2967 isp = (ispsoftc_t *)cam_sim_softc(sim); 2968 ISP_ASSERT_LOCKED(isp); 2969 bus = cam_sim_bus(sim); 2970 isp_prt(isp, ISP_LOGDEBUG2, "isp_action code %x", ccb->ccb_h.func_code); 2971 ISP_PCMD(ccb) = NULL; --- 33 unchanged lines hidden (view full) --- 3005 ccb->ccb_h.status = CAM_REQUEUE_REQ; 3006 xpt_done(ccb); 3007 break; 3008 } 3009 error = isp_start((XS_T *) ccb); 3010 switch (error) { 3011 case CMD_QUEUED: 3012 ccb->ccb_h.status |= CAM_SIM_QUEUED; | 2965 2966 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("isp_action\n")); 2967 2968 isp = (ispsoftc_t *)cam_sim_softc(sim); 2969 ISP_ASSERT_LOCKED(isp); 2970 bus = cam_sim_bus(sim); 2971 isp_prt(isp, ISP_LOGDEBUG2, "isp_action code %x", ccb->ccb_h.func_code); 2972 ISP_PCMD(ccb) = NULL; --- 33 unchanged lines hidden (view full) --- 3006 ccb->ccb_h.status = CAM_REQUEUE_REQ; 3007 xpt_done(ccb); 3008 break; 3009 } 3010 error = isp_start((XS_T *) ccb); 3011 switch (error) { 3012 case CMD_QUEUED: 3013 ccb->ccb_h.status |= CAM_SIM_QUEUED; |
3013 if (ccb->ccb_h.timeout == CAM_TIME_INFINITY) { | 3014 if (ccb->ccb_h.timeout == CAM_TIME_INFINITY) |
3014 break; | 3015 break; |
3015 } 3016 ts = ccb->ccb_h.timeout; 3017 if (ts == CAM_TIME_DEFAULT) { 3018 ts = 60*1000; 3019 } 3020 ts = isp_mstohz(ts); 3021 callout_reset(&PISP_PCMD(ccb)->wdog, ts, isp_watchdog, ccb); | 3016 /* Give firmware extra 10s to handle timeout. */ 3017 ts = SBT_1MS * ccb->ccb_h.timeout + 10 * SBT_1S; 3018 callout_reset_sbt(&PISP_PCMD(ccb)->wdog, ts, 0, 3019 isp_watchdog, ccb, 0); |
3022 break; 3023 case CMD_RQLATER: 3024 isp_prt(isp, ISP_LOGDEBUG0, "%d.%jx retry later", 3025 XS_TGT(ccb), (uintmax_t)XS_LUN(ccb)); 3026 cam_freeze_devq(ccb->ccb_h.path); 3027 cam_release_devq(ccb->ccb_h.path, RELSIM_RELEASE_AFTER_TIMEOUT, 0, 1000, 0); 3028 ccb->ccb_h.status = CAM_REQUEUE_REQ; 3029 isp_free_pcmd(isp, ccb); --- 1062 unchanged lines hidden (view full) --- 4092 if (isp->isp_osinfo.pc.fc[chan].fcbsy) { 4093 ret = -1; 4094 } else { 4095 isp->isp_osinfo.pc.fc[chan].fcbsy = 1; 4096 } 4097 return (ret); 4098} 4099 | 3020 break; 3021 case CMD_RQLATER: 3022 isp_prt(isp, ISP_LOGDEBUG0, "%d.%jx retry later", 3023 XS_TGT(ccb), (uintmax_t)XS_LUN(ccb)); 3024 cam_freeze_devq(ccb->ccb_h.path); 3025 cam_release_devq(ccb->ccb_h.path, RELSIM_RELEASE_AFTER_TIMEOUT, 0, 1000, 0); 3026 ccb->ccb_h.status = CAM_REQUEUE_REQ; 3027 isp_free_pcmd(isp, ccb); --- 1062 unchanged lines hidden (view full) --- 4090 if (isp->isp_osinfo.pc.fc[chan].fcbsy) { 4091 ret = -1; 4092 } else { 4093 isp->isp_osinfo.pc.fc[chan].fcbsy = 1; 4094 } 4095 return (ret); 4096} 4097 |
4100int 4101isp_mstohz(int ms) 4102{ 4103 int hz; 4104 struct timeval t; 4105 t.tv_sec = ms / 1000; 4106 t.tv_usec = (ms % 1000) * 1000; 4107 hz = tvtohz(&t); 4108 if (hz < 0) { 4109 hz = 0x7fffffff; 4110 } 4111 if (hz == 0) { 4112 hz = 1; 4113 } 4114 return (hz); 4115} 4116 | |
4117void 4118isp_platform_intr(void *arg) 4119{ 4120 ispsoftc_t *isp = arg; 4121 4122 ISP_LOCK(isp); 4123 ISP_RUN_ISR(isp); 4124 ISP_UNLOCK(isp); --- 143 unchanged lines hidden --- | 4098void 4099isp_platform_intr(void *arg) 4100{ 4101 ispsoftc_t *isp = arg; 4102 4103 ISP_LOCK(isp); 4104 ISP_RUN_ISR(isp); 4105 ISP_UNLOCK(isp); --- 143 unchanged lines hidden --- |