Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec891462 authored by Joe Carnuccio's avatar Joe Carnuccio Committed by Martin K. Petersen
Browse files

qla2xxx: Add bsg interface to support D_Port Diagnostics.

parent 783e0dc4
Loading
Loading
Loading
Loading
+44 −0
Original line number Original line Diff line number Diff line
@@ -2295,6 +2295,47 @@ qla2x00_get_priv_stats(struct fc_bsg_job *bsg_job)
	return rval;
	return rval;
}
}


static int
qla2x00_do_dport_diagnostics(struct fc_bsg_job *bsg_job)
{
	struct Scsi_Host *host = bsg_job->shost;
	scsi_qla_host_t *vha = shost_priv(host);
	int rval;
	struct qla_dport_diag *dd;

	if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw))
		return -EPERM;

	dd = kmalloc(sizeof(*dd), GFP_KERNEL);
	if (!dd) {
		ql_log(ql_log_warn, vha, 0x70db,
		    "Failed to allocate memory for dport.\n");
		return -ENOMEM;
	}

	sg_copy_to_buffer(bsg_job->request_payload.sg_list,
	    bsg_job->request_payload.sg_cnt, dd, sizeof(*dd));

	rval = qla26xx_dport_diagnostics(
	    vha, dd->buf, sizeof(dd->buf), dd->options);
	if (rval == QLA_SUCCESS) {
		sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
		    bsg_job->reply_payload.sg_cnt, dd, sizeof(*dd));
	}

	bsg_job->reply->reply_payload_rcv_len = sizeof(*dd);
	bsg_job->reply->reply_data.vendor_reply.vendor_rsp[0] =
	    rval ? EXT_STATUS_MAILBOX : EXT_STATUS_OK;

	bsg_job->reply_len = sizeof(*bsg_job->reply);
	bsg_job->reply->result = DID_OK << 16;
	bsg_job->job_done(bsg_job);

	kfree(dd);

	return 0;
}

static int
static int
qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job)
qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job)
{
{
@@ -2362,6 +2403,9 @@ qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job)
	case QL_VND_GET_PRIV_STATS:
	case QL_VND_GET_PRIV_STATS:
		return qla2x00_get_priv_stats(bsg_job);
		return qla2x00_get_priv_stats(bsg_job);


	case QL_VND_DPORT_DIAGNOSTICS:
		return qla2x00_do_dport_diagnostics(bsg_job);

	default:
	default:
		return -ENOSYS;
		return -ENOSYS;
	}
	}
+12 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
#define QL_VND_SET_FLASH_UPDATE_CAPS    0x16
#define QL_VND_SET_FLASH_UPDATE_CAPS    0x16
#define QL_VND_GET_BBCR_DATA    0x17
#define QL_VND_GET_BBCR_DATA    0x17
#define QL_VND_GET_PRIV_STATS	0x18
#define QL_VND_GET_PRIV_STATS	0x18
#define QL_VND_DPORT_DIAGNOSTICS	0x19


/* BSG Vendor specific subcode returns */
/* BSG Vendor specific subcode returns */
#define EXT_STATUS_OK			0
#define EXT_STATUS_OK			0
@@ -266,4 +267,15 @@ struct qla_bbcr_data {
	uint16_t  mbx1;			/* Port state */
	uint16_t  mbx1;			/* Port state */
	uint8_t   reserved[9];
	uint8_t   reserved[9];
} __packed;
} __packed;

struct qla_dport_diag {
	uint16_t options;
	uint32_t buf[16];
	uint8_t  unused[62];
} __packed;

/* D_Port options */
#define QLA_DPORT_RESULT	0x0
#define QLA_DPORT_START		0x2

#endif
#endif
+1 −2
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
 * | Module Init and Probe        |       0x018f       | 0x0146         |
 * | Module Init and Probe        |       0x018f       | 0x0146         |
 * |                              |                    | 0x015b-0x0160	|
 * |                              |                    | 0x015b-0x0160	|
 * |                              |                    | 0x016e		|
 * |                              |                    | 0x016e		|
 * | Mailbox commands             |       0x1191       | 		|
 * | Mailbox commands             |       0x1196       |		|
 * |                              |                    |		|
 * |                              |                    |		|
 * | Device Discovery             |       0x2003       | 0x2016		|
 * | Device Discovery             |       0x2003       | 0x2016		|
 * |                              |                    | 0x2011-0x2012, |
 * |                              |                    | 0x2011-0x2012, |
@@ -41,7 +41,6 @@
 * |                              |                    | 0x70ad-0x70ae  |
 * |                              |                    | 0x70ad-0x70ae  |
 * |                              |                    | 0x70d0-0x70d6	|
 * |                              |                    | 0x70d0-0x70d6	|
 * |                              |                    | 0x70d7-0x70db  |
 * |                              |                    | 0x70d7-0x70db  |
 * |                              |                    | 0x70db		|
 * | Task Management              |       0x803d       | 0x8000,0x800b  |
 * | Task Management              |       0x803d       | 0x8000,0x800b  |
 * |                              |                    | 0x8019         |
 * |                              |                    | 0x8019         |
 * |                              |                    | 0x8025,0x8026  |
 * |                              |                    | 0x8025,0x8026  |
+3 −0
Original line number Original line Diff line number Diff line
@@ -445,6 +445,9 @@ qla2x00_port_logout(scsi_qla_host_t *, struct fc_port *);
extern int
extern int
qla2x00_dump_mctp_data(scsi_qla_host_t *, dma_addr_t, uint32_t, uint32_t);
qla2x00_dump_mctp_data(scsi_qla_host_t *, dma_addr_t, uint32_t, uint32_t);


extern int
qla26xx_dport_diagnostics(scsi_qla_host_t *, void *, uint, uint);

/*
/*
 * Global Function Prototypes in qla_isr.c source file.
 * Global Function Prototypes in qla_isr.c source file.
 */
 */
+5 −2
Original line number Original line Diff line number Diff line
@@ -1152,10 +1152,13 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)


	case MBA_DPORT_DIAGNOSTICS:
	case MBA_DPORT_DIAGNOSTICS:
		ql_dbg(ql_dbg_async, vha, 0x5052,
		ql_dbg(ql_dbg_async, vha, 0x5052,
		    "D-Port Diagnostics: %04x %04x=%s\n", mb[0], mb[1],
		    "D-Port Diagnostics: %04x result=%s index=%u size=%u\n",
		    mb[0],
		    mb[1] == 0 ? "start" :
		    mb[1] == 0 ? "start" :
		    mb[1] == 1 ? "done (ok)" :
		    mb[1] == 1 ? "done (ok)" :
		    mb[1] == 2 ? "done (error)" : "other");
		    mb[1] == 2 ? "done (error)" : "other",
		    LSB(mb[2]),
		    mb[3]);
		break;
		break;


	case MBA_TEMPERATURE_ALERT:
	case MBA_TEMPERATURE_ALERT:
Loading