Deleted Added
full compact
isp.c (291510) isp.c (291511)
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 *

--- 33 unchanged lines hidden (view full) ---

42 */
43#ifdef __NetBSD__
44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD$");
46#include <dev/ic/isp_netbsd.h>
47#endif
48#ifdef __FreeBSD__
49#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 *

--- 33 unchanged lines hidden (view full) ---

42 */
43#ifdef __NetBSD__
44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD$");
46#include <dev/ic/isp_netbsd.h>
47#endif
48#ifdef __FreeBSD__
49#include <sys/cdefs.h>
50__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp.c 291510 2015-11-30 21:37:22Z mav $");
50__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp.c 291511 2015-11-30 21:38:05Z mav $");
51#include <dev/isp/isp_freebsd.h>
52#endif
53#ifdef __OpenBSD__
54#include <dev/ic/isp_openbsd.h>
55#endif
56#ifdef __linux__
57#include "isp_linux.h"
58#endif

--- 61 unchanged lines hidden (view full) ---

120static int isp_pdb_sync(ispsoftc_t *, int);
121static int isp_scan_loop(ispsoftc_t *, int);
122static int isp_gid_ft_sns(ispsoftc_t *, int);
123static int isp_gid_ft_ct_passthru(ispsoftc_t *, int);
124static int isp_scan_fabric(ispsoftc_t *, int);
125static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *);
126static int isp_register_fc4_type(ispsoftc_t *, int);
127static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
51#include <dev/isp/isp_freebsd.h>
52#endif
53#ifdef __OpenBSD__
54#include <dev/ic/isp_openbsd.h>
55#endif
56#ifdef __linux__
57#include "isp_linux.h"
58#endif

--- 61 unchanged lines hidden (view full) ---

120static int isp_pdb_sync(ispsoftc_t *, int);
121static int isp_scan_loop(ispsoftc_t *, int);
122static int isp_gid_ft_sns(ispsoftc_t *, int);
123static int isp_gid_ft_ct_passthru(ispsoftc_t *, int);
124static int isp_scan_fabric(ispsoftc_t *, int);
125static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *);
126static int isp_register_fc4_type(ispsoftc_t *, int);
127static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
128static int isp_register_fc4_features_24xx(ispsoftc_t *, int);
128static uint16_t isp_next_handle(ispsoftc_t *, uint16_t *);
129static int isp_fw_state(ispsoftc_t *, int);
130static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
131static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
132
133static void isp_spi_update(ispsoftc_t *, int);
134static void isp_setdfltsdparm(ispsoftc_t *);
135static void isp_setdfltfcparm(ispsoftc_t *, int);

--- 2786 unchanged lines hidden (view full) ---

2922 * The mbs is still hanging out from the MBOX_GET_LOOP_ID above.
2923 */
2924 fcp->isp_fabric_params = mbs.param[7];
2925 } else {
2926 fcp->isp_fabric_params = 0;
2927 }
2928 fcp->isp_sns_hdl = NPH_SNS_ID;
2929 r = isp_register_fc4_type_24xx(isp, chan);
129static uint16_t isp_next_handle(ispsoftc_t *, uint16_t *);
130static int isp_fw_state(ispsoftc_t *, int);
131static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
132static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
133
134static void isp_spi_update(ispsoftc_t *, int);
135static void isp_setdfltsdparm(ispsoftc_t *);
136static void isp_setdfltfcparm(ispsoftc_t *, int);

--- 2786 unchanged lines hidden (view full) ---

2923 * The mbs is still hanging out from the MBOX_GET_LOOP_ID above.
2924 */
2925 fcp->isp_fabric_params = mbs.param[7];
2926 } else {
2927 fcp->isp_fabric_params = 0;
2928 }
2929 fcp->isp_sns_hdl = NPH_SNS_ID;
2930 r = isp_register_fc4_type_24xx(isp, chan);
2931 if (r == 0)
2932 isp_register_fc4_features_24xx(isp, chan);
2930 } else {
2931 fcp->isp_sns_hdl = SNS_ID;
2932 r = isp_register_fc4_type(isp, chan);
2933 }
2934 if (r) {
2935 isp_prt(isp, ISP_LOGWARN|ISP_LOG_SANCFG, "%s: register fc4 type failed", __func__);
2936 return (-1);
2937 }

--- 1274 unchanged lines hidden (view full) ---

4212 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Register FC4 Type accepted", chan);
4213 return (0);
4214 } else {
4215 isp_prt(isp, ISP_LOGWARN, "Chan %d Register FC4 Type: 0x%x", chan, ct->ct_cmd_resp);
4216 return (-1);
4217 }
4218}
4219
2933 } else {
2934 fcp->isp_sns_hdl = SNS_ID;
2935 r = isp_register_fc4_type(isp, chan);
2936 }
2937 if (r) {
2938 isp_prt(isp, ISP_LOGWARN|ISP_LOG_SANCFG, "%s: register fc4 type failed", __func__);
2939 return (-1);
2940 }

--- 1274 unchanged lines hidden (view full) ---

4215 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Register FC4 Type accepted", chan);
4216 return (0);
4217 } else {
4218 isp_prt(isp, ISP_LOGWARN, "Chan %d Register FC4 Type: 0x%x", chan, ct->ct_cmd_resp);
4219 return (-1);
4220 }
4221}
4222
4223static int
4224isp_register_fc4_features_24xx(ispsoftc_t *isp, int chan)
4225{
4226 mbreg_t mbs;
4227 fcparam *fcp = FCPARAM(isp, chan);
4228 union {
4229 isp_ct_pt_t plocal;
4230 rff_id_t clocal;
4231 uint8_t q[QENTRY_LEN];
4232 } un;
4233 isp_ct_pt_t *pt;
4234 ct_hdr_t *ct;
4235 rff_id_t *rp;
4236 uint8_t *scp = fcp->isp_scratch;
4237
4238 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4239 isp_prt(isp, ISP_LOGERR, sacq);
4240 return (-1);
4241 }
4242
4243 /*
4244 * Build a Passthrough IOCB in memory.
4245 */
4246 ISP_MEMZERO(un.q, QENTRY_LEN);
4247 pt = &un.plocal;
4248 pt->ctp_header.rqs_entry_count = 1;
4249 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
4250 pt->ctp_handle = 0xffffffff;
4251 pt->ctp_nphdl = fcp->isp_sns_hdl;
4252 pt->ctp_cmd_cnt = 1;
4253 pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
4254 pt->ctp_time = 1;
4255 pt->ctp_rsp_cnt = 1;
4256 pt->ctp_rsp_bcnt = sizeof (ct_hdr_t);
4257 pt->ctp_cmd_bcnt = sizeof (rff_id_t);
4258 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
4259 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
4260 pt->ctp_dataseg[0].ds_count = sizeof (rff_id_t);
4261 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);
4262 pt->ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma+IGPOFF);
4263 pt->ctp_dataseg[1].ds_count = sizeof (ct_hdr_t);
4264 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
4265 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4266 isp_print_bytes(isp, "IOCB CT Request", QENTRY_LEN, pt);
4267 }
4268
4269 /*
4270 * Build the CT header and command in memory.
4271 *
4272 * Note that the CT header has to end up as Big Endian format in memory.
4273 */
4274 ISP_MEMZERO(&un.clocal, sizeof (un.clocal));
4275 ct = &un.clocal.rffid_hdr;
4276 ct->ct_revision = CT_REVISION;
4277 ct->ct_fcs_type = CT_FC_TYPE_FC;
4278 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
4279 ct->ct_cmd_resp = SNS_RFF_ID;
4280 ct->ct_bcnt_resid = (sizeof (rff_id_t) - sizeof (ct_hdr_t)) >> 2;
4281 rp = &un.clocal;
4282 rp->rffid_portid[0] = fcp->isp_portid >> 16;
4283 rp->rffid_portid[1] = fcp->isp_portid >> 8;
4284 rp->rffid_portid[2] = fcp->isp_portid;
4285 rp->rffid_fc4features = 0;
4286 if (fcp->role & ISP_ROLE_TARGET)
4287 rp->rffid_fc4features |= 1;
4288 if (fcp->role & ISP_ROLE_INITIATOR)
4289 rp->rffid_fc4features |= 2;
4290 rp->rffid_fc4type = FC4_SCSI;
4291 isp_put_rff_id(isp, rp, (rff_id_t *) &scp[XTXOFF]);
4292 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4293 isp_print_bytes(isp, "CT Header", QENTRY_LEN, &scp[XTXOFF]);
4294 }
4295
4296 ISP_MEMZERO(&scp[ZTXOFF], sizeof (ct_hdr_t));
4297
4298 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 1000000);
4299 mbs.param[1] = QENTRY_LEN;
4300 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
4301 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
4302 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
4303 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
4304 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN, chan);
4305 isp_mboxcmd(isp, &mbs);
4306 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4307 FC_SCRATCH_RELEASE(isp, chan);
4308 return (-1);
4309 }
4310 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN, chan);
4311 pt = &un.plocal;
4312 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
4313 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4314 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
4315 }
4316 if (pt->ctp_status) {
4317 FC_SCRATCH_RELEASE(isp, chan);
4318 isp_prt(isp, ISP_LOGWARN,
4319 "Chan %d Register FC4 Features CT Passthrough returned 0x%x",
4320 chan, pt->ctp_status);
4321 return (1);
4322 }
4323
4324 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct);
4325 FC_SCRATCH_RELEASE(isp, chan);
4326
4327 if (ct->ct_cmd_resp == LS_RJT) {
4328 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1,
4329 "Chan %d Register FC4 Features rejected", chan);
4330 return (-1);
4331 } else if (ct->ct_cmd_resp == LS_ACC) {
4332 isp_prt(isp, ISP_LOG_SANCFG,
4333 "Chan %d Register FC4 Features accepted", chan);
4334 return (0);
4335 } else {
4336 isp_prt(isp, ISP_LOGWARN,
4337 "Chan %d Register FC4 Features: 0x%x", chan, ct->ct_cmd_resp);
4338 return (-1);
4339 }
4340}
4341
4220static uint16_t
4221isp_next_handle(ispsoftc_t *isp, uint16_t *ohp)
4222{
4223 fcparam *fcp;
4224 int i, chan, wrap;
4225 uint16_t handle, minh, maxh;
4226
4227 handle = *ohp;

--- 4269 unchanged lines hidden ---
4342static uint16_t
4343isp_next_handle(ispsoftc_t *isp, uint16_t *ohp)
4344{
4345 fcparam *fcp;
4346 int i, chan, wrap;
4347 uint16_t handle, minh, maxh;
4348
4349 handle = *ohp;

--- 4269 unchanged lines hidden ---