Deleted Added
full compact
isp_freebsd.c (290786) isp_freebsd.c (290787)
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/10/sys/dev/isp/isp_freebsd.c 290786 2015-11-13 19:43:58Z mav $");
31__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp_freebsd.c 290787 2015-11-13 19:45:15Z 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>

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

2475 /*
2476 * If we're not in the port database, add ourselves.
2477 */
2478 if (IS_2100(isp))
2479 atiop->init_id = nphdl;
2480 else {
2481 if ((isp_find_pdb_by_handle(isp, 0, nphdl, &lp) == 0 ||
2482 lp->state == FC_PORTDB_STATE_ZOMBIE)) {
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>

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

2475 /*
2476 * If we're not in the port database, add ourselves.
2477 */
2478 if (IS_2100(isp))
2479 atiop->init_id = nphdl;
2480 else {
2481 if ((isp_find_pdb_by_handle(isp, 0, nphdl, &lp) == 0 ||
2482 lp->state == FC_PORTDB_STATE_ZOMBIE)) {
2483 uint64_t iid =
2483 uint64_t wwpn =
2484 (((uint64_t) aep->at_wwpn[0]) << 48) |
2485 (((uint64_t) aep->at_wwpn[1]) << 32) |
2486 (((uint64_t) aep->at_wwpn[2]) << 16) |
2487 (((uint64_t) aep->at_wwpn[3]) << 0);
2484 (((uint64_t) aep->at_wwpn[0]) << 48) |
2485 (((uint64_t) aep->at_wwpn[1]) << 32) |
2486 (((uint64_t) aep->at_wwpn[2]) << 16) |
2487 (((uint64_t) aep->at_wwpn[3]) << 0);
2488 isp_add_wwn_entry(isp, 0, iid, nphdl, PORT_ANY, 0);
2488 isp_add_wwn_entry(isp, 0, wwpn, INI_NONE,
2489 nphdl, PORT_ANY, 0);
2489 isp_find_pdb_by_handle(isp, 0, nphdl, &lp);
2490 }
2491 atiop->init_id = FC_PORTDB_TGT(isp, 0, lp);
2492 }
2493 atiop->cdb_len = ATIO2_CDBLEN;
2494 ISP_MEMCPY(atiop->cdb_io.cdb_bytes, aep->at_cdb, ATIO2_CDBLEN);
2495 atiop->ccb_h.status = CAM_CDB_RECVD;
2496 atiop->tag_id = atp->tag;

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

3190
3191static void
3192isp_handle_platform_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *inot)
3193{
3194 uint16_t nphdl;
3195 uint16_t prli_options = 0;
3196 uint32_t portid;
3197 fcportdb_t *lp;
2490 isp_find_pdb_by_handle(isp, 0, nphdl, &lp);
2491 }
2492 atiop->init_id = FC_PORTDB_TGT(isp, 0, lp);
2493 }
2494 atiop->cdb_len = ATIO2_CDBLEN;
2495 ISP_MEMCPY(atiop->cdb_io.cdb_bytes, aep->at_cdb, ATIO2_CDBLEN);
2496 atiop->ccb_h.status = CAM_CDB_RECVD;
2497 atiop->tag_id = atp->tag;

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

3191
3192static void
3193isp_handle_platform_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *inot)
3194{
3195 uint16_t nphdl;
3196 uint16_t prli_options = 0;
3197 uint32_t portid;
3198 fcportdb_t *lp;
3198 uint8_t *ptr = NULL;
3199 uint64_t wwn;
3199 char *msg = NULL;
3200 uint8_t *ptr = (uint8_t *)inot;
3201 uint64_t wwpn = INI_NONE, wwnn = INI_NONE;
3200
3201 nphdl = inot->in_nphdl;
3202 if (nphdl != NIL_HANDLE) {
3203 portid = inot->in_portid_hi << 16 | inot->in_portid_lo;
3204 } else {
3205 portid = PORT_ANY;
3206 }
3207
3208 switch (inot->in_status) {
3209 case IN24XX_ELS_RCVD:
3210 {
3202
3203 nphdl = inot->in_nphdl;
3204 if (nphdl != NIL_HANDLE) {
3205 portid = inot->in_portid_hi << 16 | inot->in_portid_lo;
3206 } else {
3207 portid = PORT_ANY;
3208 }
3209
3210 switch (inot->in_status) {
3211 case IN24XX_ELS_RCVD:
3212 {
3211 char buf[16], *msg;
3213 char buf[16];
3212 int chan = ISP_GET_VPIDX(isp, inot->in_vpidx);
3213
3214 /*
3215 * Note that we're just getting notification that an ELS was received
3216 * (possibly with some associated information sent upstream). This is
3217 * *not* the same as being given the ELS frame to accept or reject.
3218 */
3219 switch (inot->in_status_subcode) {
3220 case LOGO:
3221 msg = "LOGO";
3214 int chan = ISP_GET_VPIDX(isp, inot->in_vpidx);
3215
3216 /*
3217 * Note that we're just getting notification that an ELS was received
3218 * (possibly with some associated information sent upstream). This is
3219 * *not* the same as being given the ELS frame to accept or reject.
3220 */
3221 switch (inot->in_status_subcode) {
3222 case LOGO:
3223 msg = "LOGO";
3222 if (ISP_FW_NEWER_THAN(isp, 4, 0, 25)) {
3223 ptr = (uint8_t *)inot; /* point to unswizzled entry! */
3224 wwn = (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF]) << 56) |
3225 (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF+1]) << 48) |
3226 (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF+2]) << 40) |
3227 (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF+3]) << 32) |
3228 (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF+4]) << 24) |
3229 (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF+5]) << 16) |
3230 (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF+6]) << 8) |
3231 (((uint64_t) ptr[IN24XX_LOGO_WWPN_OFF+7]));
3232 } else {
3233 wwn = INI_ANY;
3234 }
3235 isp_del_wwn_entry(isp, chan, wwn, nphdl, portid);
3224 wwpn = be64dec(&ptr[IN24XX_PLOGI_WWPN_OFF]);
3225 isp_del_wwn_entry(isp, chan, wwpn, nphdl, portid);
3236 break;
3237 case PRLO:
3238 msg = "PRLO";
3239 break;
3240 case PLOGI:
3226 break;
3227 case PRLO:
3228 msg = "PRLO";
3229 break;
3230 case PLOGI:
3231 msg = "PLOGI";
3232 wwnn = be64dec(&ptr[IN24XX_PLOGI_WWNN_OFF]);
3233 wwpn = be64dec(&ptr[IN24XX_PLOGI_WWPN_OFF]);
3234 isp_add_wwn_entry(isp, chan, wwpn, wwnn,
3235 nphdl, portid, prli_options);
3236 break;
3241 case PRLI:
3237 case PRLI:
3242 /*
3243 * Treat PRLI the same as PLOGI and make a database entry for it.
3244 */
3245 if (inot->in_status_subcode == PLOGI) {
3246 msg = "PLOGI";
3247 } else {
3248 prli_options = inot->in_prli_options;
3249 msg = "PRLI";
3250 }
3251 if (ISP_FW_NEWER_THAN(isp, 4, 0, 25)) {
3252 ptr = (uint8_t *)inot; /* point to unswizzled entry! */
3253 wwn = (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF]) << 56) |
3254 (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF+1]) << 48) |
3255 (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF+2]) << 40) |
3256 (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF+3]) << 32) |
3257 (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF+4]) << 24) |
3258 (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF+5]) << 16) |
3259 (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF+6]) << 8) |
3260 (((uint64_t) ptr[IN24XX_PLOGI_WWPN_OFF+7]));
3261 } else {
3262 wwn = INI_NONE;
3263 }
3264 isp_add_wwn_entry(isp, chan, wwn, nphdl, portid, prli_options);
3238 msg = "PRLI";
3239 prli_options = inot->in_prli_options;
3240 if (inot->in_flags & IN24XX_FLAG_PN_NN_VALID)
3241 wwnn = be64dec(&ptr[IN24XX_PRLI_WWNN_OFF]);
3242 wwpn = be64dec(&ptr[IN24XX_PRLI_WWPN_OFF]);
3243 isp_add_wwn_entry(isp, chan, wwpn, wwnn,
3244 nphdl, portid, prli_options);
3265 break;
3266 case PDISC:
3267 msg = "PDISC";
3268 break;
3269 case ADISC:
3270 msg = "ADISC";
3271 break;
3272 default:

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

3280 }
3281 isp_prt(isp, ISP_LOGTDEBUG0, "%s Chan %d ELS N-port handle %x PortID 0x%06x RX_ID 0x%x OX_ID 0x%x", msg, chan, nphdl, portid,
3282 inot->in_rxid, inot->in_oxid);
3283 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3284 break;
3285 }
3286
3287 case IN24XX_PORT_LOGOUT:
3245 break;
3246 case PDISC:
3247 msg = "PDISC";
3248 break;
3249 case ADISC:
3250 msg = "ADISC";
3251 break;
3252 default:

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

3260 }
3261 isp_prt(isp, ISP_LOGTDEBUG0, "%s Chan %d ELS N-port handle %x PortID 0x%06x RX_ID 0x%x OX_ID 0x%x", msg, chan, nphdl, portid,
3262 inot->in_rxid, inot->in_oxid);
3263 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3264 break;
3265 }
3266
3267 case IN24XX_PORT_LOGOUT:
3288 ptr = "PORT LOGOUT";
3268 msg = "PORT LOGOUT";
3289 if (isp_find_pdb_by_handle(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), nphdl, &lp)) {
3290 isp_del_wwn_entry(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), lp->port_wwn, nphdl, lp->portid);
3291 }
3292 /* FALLTHROUGH */
3293 case IN24XX_PORT_CHANGED:
3269 if (isp_find_pdb_by_handle(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), nphdl, &lp)) {
3270 isp_del_wwn_entry(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), lp->port_wwn, nphdl, lp->portid);
3271 }
3272 /* FALLTHROUGH */
3273 case IN24XX_PORT_CHANGED:
3294 if (ptr == NULL) {
3295 ptr = "PORT CHANGED";
3296 }
3274 if (msg == NULL)
3275 msg = "PORT CHANGED";
3297 /* FALLTHROUGH */
3276 /* FALLTHROUGH */
3298 case IN24XX_LIP_RESET:
3299 if (ptr == NULL) {
3300 ptr = "LIP RESET";
3301 }
3302 isp_prt(isp, ISP_LOGINFO, "Chan %d %s (sub-status 0x%x) for N-port handle 0x%x", ISP_GET_VPIDX(isp, inot->in_vpidx), ptr, inot->in_status_subcode, nphdl);
3277 case IN24XX_LIP_RESET:
3278 if (msg == NULL)
3279 msg = "LIP RESET";
3280 isp_prt(isp, ISP_LOGINFO, "Chan %d %s (sub-status 0x%x) for N-port handle 0x%x", ISP_GET_VPIDX(isp, inot->in_vpidx), msg, inot->in_status_subcode, nphdl);
3303
3304 /*
3305 * All subcodes here are irrelevant. What is relevant
3306 * is that we need to terminate all active commands from
3307 * this initiator (known by N-port handle).
3308 */
3309 /* XXX IMPLEMENT XXX */
3310 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3311 break;
3312
3313 case IN24XX_SRR_RCVD:
3314#ifdef ISP_TARGET_MODE
3315 isp_handle_srr_notify(isp, inot);
3316 break;
3317#else
3281
3282 /*
3283 * All subcodes here are irrelevant. What is relevant
3284 * is that we need to terminate all active commands from
3285 * this initiator (known by N-port handle).
3286 */
3287 /* XXX IMPLEMENT XXX */
3288 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3289 break;
3290
3291 case IN24XX_SRR_RCVD:
3292#ifdef ISP_TARGET_MODE
3293 isp_handle_srr_notify(isp, inot);
3294 break;
3295#else
3318 if (ptr == NULL) {
3319 ptr = "SRR RCVD";
3320 }
3296 if (msg == NULL)
3297 msg = "SRR RCVD";
3321 /* FALLTHROUGH */
3322#endif
3323 case IN24XX_LINK_RESET:
3298 /* FALLTHROUGH */
3299#endif
3300 case IN24XX_LINK_RESET:
3324 if (ptr == NULL) {
3325 ptr = "LINK RESET";
3326 }
3301 if (msg == NULL)
3302 msg = "LINK RESET";
3327 case IN24XX_LINK_FAILED:
3303 case IN24XX_LINK_FAILED:
3328 if (ptr == NULL) {
3329 ptr = "LINK FAILED";
3330 }
3304 if (msg == NULL)
3305 msg = "LINK FAILED";
3331 default:
3306 default:
3332 isp_prt(isp, ISP_LOGWARN, "Chan %d %s", ISP_GET_VPIDX(isp, inot->in_vpidx), ptr);
3307 isp_prt(isp, ISP_LOGWARN, "Chan %d %s", ISP_GET_VPIDX(isp, inot->in_vpidx), msg);
3333 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3334 break;
3335 }
3336}
3337
3338static int
3339isp_handle_platform_target_notify_ack(ispsoftc_t *isp, isp_notify_t *mp)
3340{

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

5699 if (IS_FC(isp)) {
5700 xpt_async(AC_BUS_RESET, ISP_FC_PC(isp, bus)->path, NULL);
5701 } else {
5702 xpt_async(AC_BUS_RESET, ISP_SPI_PC(isp, bus)->path, NULL);
5703 }
5704 break;
5705 }
5706 case ISPASYNC_LIP:
3308 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3309 break;
3310 }
3311}
3312
3313static int
3314isp_handle_platform_target_notify_ack(ispsoftc_t *isp, isp_notify_t *mp)
3315{

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

5674 if (IS_FC(isp)) {
5675 xpt_async(AC_BUS_RESET, ISP_FC_PC(isp, bus)->path, NULL);
5676 } else {
5677 xpt_async(AC_BUS_RESET, ISP_SPI_PC(isp, bus)->path, NULL);
5678 }
5679 break;
5680 }
5681 case ISPASYNC_LIP:
5707 if (msg == NULL) {
5682 if (msg == NULL)
5708 msg = "LIP Received";
5683 msg = "LIP Received";
5709 }
5710 /* FALLTHROUGH */
5711 case ISPASYNC_LOOP_RESET:
5684 /* FALLTHROUGH */
5685 case ISPASYNC_LOOP_RESET:
5712 if (msg == NULL) {
5686 if (msg == NULL)
5713 msg = "LOOP Reset";
5687 msg = "LOOP Reset";
5714 }
5715 /* FALLTHROUGH */
5716 case ISPASYNC_LOOP_DOWN:
5717 {
5688 /* FALLTHROUGH */
5689 case ISPASYNC_LOOP_DOWN:
5690 {
5718 if (msg == NULL) {
5691 if (msg == NULL)
5719 msg = "LOOP Down";
5692 msg = "LOOP Down";
5720 }
5721 va_start(ap, cmd);
5722 bus = va_arg(ap, int);
5723 va_end(ap);
5724
5725 FCPARAM(isp, bus)->isp_linkstate = 0;
5726
5727 fc = ISP_FC_PC(isp, bus);
5728 if (cmd == ISPASYNC_LOOP_DOWN && fc->ready) {

--- 748 unchanged lines hidden ---
5693 va_start(ap, cmd);
5694 bus = va_arg(ap, int);
5695 va_end(ap);
5696
5697 FCPARAM(isp, bus)->isp_linkstate = 0;
5698
5699 fc = ISP_FC_PC(isp, bus);
5700 if (cmd == ISPASYNC_LOOP_DOWN && fc->ready) {

--- 748 unchanged lines hidden ---