Пример #1
0
int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
                                     int c, int m, void *page)
{
    struct chsc_scpd *scpd_area;
    int ccode, ret;

    if ((rfmt == 1) && !css_general_characteristics.fcs)
        return -EINVAL;
    if ((rfmt == 2) && !css_general_characteristics.cib)
        return -EINVAL;

    memset(page, 0, PAGE_SIZE);
    scpd_area = page;
    scpd_area->request.length = 0x0010;
    scpd_area->request.code = 0x0002;
    scpd_area->cssid = chpid.cssid;
    scpd_area->first_chpid = chpid.id;
    scpd_area->last_chpid = chpid.id;
    scpd_area->m = m;
    scpd_area->c = c;
    scpd_area->fmt = fmt;
    scpd_area->rfmt = rfmt;

    ccode = chsc(scpd_area);
    if (ccode > 0)
        return (ccode == 3) ? -ENODEV : -EBUSY;

    ret = chsc_error_from_response(scpd_area->response.code);
    if (ret)
        CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
                      scpd_area->response.code);
    return ret;
}
Пример #2
0
/**
 * chsc_sadc() - set adapter device controls (SADC)
 * @schid: id of the subchannel on which SADC is performed
 * @scssc: request and response block for SADC
 * @summary_indicator_addr: summary indicator address
 * @subchannel_indicator_addr: subchannel indicator address
 *
 * Returns 0 on success.
 */
int chsc_sadc(struct subchannel_id schid, struct chsc_scssc_area *scssc,
	      u64 summary_indicator_addr, u64 subchannel_indicator_addr)
{
	memset(scssc, 0, sizeof(*scssc));
	scssc->request.length = 0x0fe0;
	scssc->request.code = 0x0021;
	scssc->operation_code = 0;

	scssc->summary_indicator_addr = summary_indicator_addr;
	scssc->subchannel_indicator_addr = subchannel_indicator_addr;

	scssc->ks = PAGE_DEFAULT_KEY >> 4;
	scssc->kc = PAGE_DEFAULT_KEY >> 4;
	scssc->isc = QDIO_AIRQ_ISC;
	scssc->schid = schid;

	/* enable the time delay disablement facility */
	if (css_general_characteristics.aif_tdd)
		scssc->word_with_d_bit = 0x10000000;

	if (chsc(scssc))
		return -EIO;

	return chsc_error_from_response(scssc->response.code);
}
Пример #3
0
int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
				     int c, int m,
				     struct chsc_response_struct *resp)
{
	int ccode, ret;

	struct {
		struct chsc_header request;
		u32 : 2;
		u32 m : 1;
		u32 c : 1;
		u32 fmt : 4;
		u32 cssid : 8;
		u32 : 4;
		u32 rfmt : 4;
		u32 first_chpid : 8;
		u32 : 24;
		u32 last_chpid : 8;
		u32 zeroes1;
		struct chsc_header response;
		u8 data[PAGE_SIZE - 20];
	} __attribute__ ((packed)) *scpd_area;

	if ((rfmt == 1) && !css_general_characteristics.fcs)
		return -EINVAL;
	if ((rfmt == 2) && !css_general_characteristics.cib)
		return -EINVAL;
	scpd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
	if (!scpd_area)
		return -ENOMEM;

	scpd_area->request.length = 0x0010;
	scpd_area->request.code = 0x0002;

	scpd_area->cssid = chpid.cssid;
	scpd_area->first_chpid = chpid.id;
	scpd_area->last_chpid = chpid.id;
	scpd_area->m = m;
	scpd_area->c = c;
	scpd_area->fmt = fmt;
	scpd_area->rfmt = rfmt;

	ccode = chsc(scpd_area);
	if (ccode > 0) {
		ret = (ccode == 3) ? -ENODEV : -EBUSY;
		goto out;
	}

	ret = chsc_error_from_response(scpd_area->response.code);
	if (ret == 0)
		/* Success. */
		memcpy(resp, &scpd_area->response, scpd_area->response.length);
	else
		CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
			      scpd_area->response.code);
out:
	free_page((unsigned long)scpd_area);
	return ret;
}
Пример #4
0
int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd)
{
	unsigned long page;
	struct chsc_ssd_area *ssd_area;
	int ccode;
	int ret;
	int i;
	int mask;

	page = get_zeroed_page(GFP_KERNEL | GFP_DMA);
	if (!page)
		return -ENOMEM;
	ssd_area = (struct chsc_ssd_area *) page;
	ssd_area->request.length = 0x0010;
	ssd_area->request.code = 0x0004;
	ssd_area->ssid = schid.ssid;
	ssd_area->f_sch = schid.sch_no;
	ssd_area->l_sch = schid.sch_no;

	ccode = chsc(ssd_area);
	/* Check response. */
	if (ccode > 0) {
		ret = (ccode == 3) ? -ENODEV : -EBUSY;
		goto out_free;
	}
	ret = chsc_error_from_response(ssd_area->response.code);
	if (ret != 0) {
		CIO_MSG_EVENT(2, "chsc: ssd failed for 0.%x.%04x (rc=%04x)\n",
			      schid.ssid, schid.sch_no,
			      ssd_area->response.code);
		goto out_free;
	}
	if (!ssd_area->sch_valid) {
		ret = -ENODEV;
		goto out_free;
	}
	/* Copy data */
	ret = 0;
	memset(ssd, 0, sizeof(struct chsc_ssd_info));
	if ((ssd_area->st != SUBCHANNEL_TYPE_IO) &&
	    (ssd_area->st != SUBCHANNEL_TYPE_MSG))
		goto out_free;
	ssd->path_mask = ssd_area->path_mask;
	ssd->fla_valid_mask = ssd_area->fla_valid_mask;
	for (i = 0; i < 8; i++) {
		mask = 0x80 >> i;
		if (ssd_area->path_mask & mask) {
			chp_id_init(&ssd->chpid[i]);
			ssd->chpid[i].id = ssd_area->chpid[i];
		}
		if (ssd_area->fla_valid_mask & mask)
			ssd->fla[i] = ssd_area->fla[i];
	}
out_free:
	free_page(page);
	return ret;
}
Пример #5
0
int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd)
{
	struct chsc_ssd_area *ssd_area;
	unsigned long flags;
	int ccode;
	int ret;
	int i;
	int mask;

	spin_lock_irqsave(&chsc_page_lock, flags);
	memset(chsc_page, 0, PAGE_SIZE);
	ssd_area = chsc_page;
	ssd_area->request.length = 0x0010;
	ssd_area->request.code = 0x0004;
	ssd_area->ssid = schid.ssid;
	ssd_area->f_sch = schid.sch_no;
	ssd_area->l_sch = schid.sch_no;

	ccode = chsc(ssd_area);
	/* Check response. */
	if (ccode > 0) {
		ret = (ccode == 3) ? -ENODEV : -EBUSY;
		goto out;
	}
	ret = chsc_error_from_response(ssd_area->response.code);
	if (ret != 0) {
		CIO_MSG_EVENT(2, "chsc: ssd failed for 0.%x.%04x (rc=%04x)\n",
			      schid.ssid, schid.sch_no,
			      ssd_area->response.code);
		goto out;
	}
	if (!ssd_area->sch_valid) {
		ret = -ENODEV;
		goto out;
	}
	/* Copy data */
	ret = 0;
	memset(ssd, 0, sizeof(struct chsc_ssd_info));
	if ((ssd_area->st != SUBCHANNEL_TYPE_IO) &&
	    (ssd_area->st != SUBCHANNEL_TYPE_MSG))
		goto out;
	ssd->path_mask = ssd_area->path_mask;
	ssd->fla_valid_mask = ssd_area->fla_valid_mask;
	for (i = 0; i < 8; i++) {
		mask = 0x80 >> i;
		if (ssd_area->path_mask & mask) {
			chp_id_init(&ssd->chpid[i]);
			ssd->chpid[i].id = ssd_area->chpid[i];
		}
		if (ssd_area->fla_valid_mask & mask)
			ssd->fla[i] = ssd_area->fla[i];
	}
out:
	spin_unlock_irqrestore(&chsc_page_lock, flags);
	return ret;
}
Пример #6
0
int __chsc_do_secm(struct channel_subsystem *css, int enable)
{
    struct {
        struct chsc_header request;
        u32 operation_code : 2;
        u32 : 30;
        u32 key : 4;
        u32 : 28;
        u32 zeroes1;
        u32 cub_addr1;
        u32 zeroes2;
        u32 cub_addr2;
        u32 reserved[13];
        struct chsc_header response;
        u32 status : 8;
        u32 : 4;
        u32 fmt : 4;
        u32 : 16;
    } __attribute__ ((packed)) *secm_area;
    int ret, ccode;

    spin_lock_irq(&chsc_page_lock);
    memset(chsc_page, 0, PAGE_SIZE);
    secm_area = chsc_page;
    secm_area->request.length = 0x0050;
    secm_area->request.code = 0x0016;

    secm_area->key = PAGE_DEFAULT_KEY >> 4;
    secm_area->cub_addr1 = (u64)(unsigned long)css->cub_addr1;
    secm_area->cub_addr2 = (u64)(unsigned long)css->cub_addr2;

    secm_area->operation_code = enable ? 0 : 1;

    ccode = chsc(secm_area);
    if (ccode > 0) {
        ret = (ccode == 3) ? -ENODEV : -EBUSY;
        goto out;
    }

    switch (secm_area->response.code) {
    case 0x0102:
    case 0x0103:
        ret = -EINVAL;
        break;
    default:
        ret = chsc_error_from_response(secm_area->response.code);
    }
    if (ret != 0)
        CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n",
                      secm_area->response.code);
out:
    spin_unlock_irq(&chsc_page_lock);
    return ret;
}
Пример #7
0
/**
 * chsc_ssqd() - store subchannel QDIO data (SSQD)
 * @schid: id of the subchannel on which SSQD is performed
 * @ssqd: request and response block for SSQD
 *
 * Returns 0 on success.
 */
int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd)
{
	memset(ssqd, 0, sizeof(*ssqd));
	ssqd->request.length = 0x0010;
	ssqd->request.code = 0x0024;
	ssqd->first_sch = schid.sch_no;
	ssqd->last_sch = schid.sch_no;
	ssqd->ssid = schid.ssid;

	if (chsc(ssqd))
		return -EIO;

	return chsc_error_from_response(ssqd->response.code);
}
Пример #8
0
int chsc_enable_facility(int operation_code)
{
    unsigned long flags;
    int ret;
    struct {
        struct chsc_header request;
        u8 reserved1:4;
        u8 format:4;
        u8 reserved2;
        u16 operation_code;
        u32 reserved3;
        u32 reserved4;
        u32 operation_data_area[252];
        struct chsc_header response;
        u32 reserved5:4;
        u32 format2:4;
        u32 reserved6:24;
    } __attribute__ ((packed)) *sda_area;

    spin_lock_irqsave(&chsc_page_lock, flags);
    memset(chsc_page, 0, PAGE_SIZE);
    sda_area = chsc_page;
    sda_area->request.length = 0x0400;
    sda_area->request.code = 0x0031;
    sda_area->operation_code = operation_code;

    ret = chsc(sda_area);
    if (ret > 0) {
        ret = (ret == 3) ? -ENODEV : -EBUSY;
        goto out;
    }

    switch (sda_area->response.code) {
    case 0x0101:
        ret = -EOPNOTSUPP;
        break;
    default:
        ret = chsc_error_from_response(sda_area->response.code);
    }
    if (ret != 0)
        CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n",
                      operation_code, sda_area->response.code);
out:
    spin_unlock_irqrestore(&chsc_page_lock, flags);
    return ret;
}
Пример #9
0
int chsc_siosl(struct subchannel_id schid)
{
    struct {
        struct chsc_header request;
        u32 word1;
        struct subchannel_id sid;
        u32 word3;
        struct chsc_header response;
        u32 word[11];
    } __attribute__ ((packed)) *siosl_area;
    unsigned long flags;
    int ccode;
    int rc;

    spin_lock_irqsave(&chsc_page_lock, flags);
    memset(chsc_page, 0, PAGE_SIZE);
    siosl_area = chsc_page;
    siosl_area->request.length = 0x0010;
    siosl_area->request.code = 0x0046;
    siosl_area->word1 = 0x80000000;
    siosl_area->sid = schid;

    ccode = chsc(siosl_area);
    if (ccode > 0) {
        if (ccode == 3)
            rc = -ENODEV;
        else
            rc = -EBUSY;
        CIO_MSG_EVENT(2, "chsc: chsc failed for 0.%x.%04x (ccode=%d)\n",
                      schid.ssid, schid.sch_no, ccode);
        goto out;
    }
    rc = chsc_error_from_response(siosl_area->response.code);
    if (rc)
        CIO_MSG_EVENT(2, "chsc: siosl failed for 0.%x.%04x (rc=%04x)\n",
                      schid.ssid, schid.sch_no,
                      siosl_area->response.code);
    else
        CIO_MSG_EVENT(4, "chsc: siosl succeeded for 0.%x.%04x\n",
                      schid.ssid, schid.sch_no);
out:
    spin_unlock_irqrestore(&chsc_page_lock, flags);
    return rc;
}
Пример #10
0
/**
 * chsc_scm_info() - store SCM information (SSI)
 * @scm_area: request and response block for SSI
 * @token: continuation token
 *
 * Returns 0 on success.
 */
int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token)
{
    int ccode, ret;

    memset(scm_area, 0, sizeof(*scm_area));
    scm_area->request.length = 0x0020;
    scm_area->request.code = 0x004C;
    scm_area->reqtok = token;

    ccode = chsc(scm_area);
    if (ccode > 0) {
        ret = (ccode == 3) ? -ENODEV : -EBUSY;
        goto out;
    }
    ret = chsc_error_from_response(scm_area->response.code);
    if (ret != 0)
        CIO_MSG_EVENT(2, "chsc: scm info failed (rc=%04x)\n",
                      scm_area->response.code);
out:
    return ret;
}
Пример #11
0
int __init
chsc_determine_css_characteristics(void)
{
    int result;
    struct {
        struct chsc_header request;
        u32 reserved1;
        u32 reserved2;
        u32 reserved3;
        struct chsc_header response;
        u32 reserved4;
        u32 general_char[510];
        u32 chsc_char[508];
    } __attribute__ ((packed)) *scsc_area;

    spin_lock_irq(&chsc_page_lock);
    memset(chsc_page, 0, PAGE_SIZE);
    scsc_area = chsc_page;
    scsc_area->request.length = 0x0010;
    scsc_area->request.code = 0x0010;

    result = chsc(scsc_area);
    if (result) {
        result = (result == 3) ? -ENODEV : -EBUSY;
        goto exit;
    }

    result = chsc_error_from_response(scsc_area->response.code);
    if (result == 0) {
        memcpy(&css_general_characteristics, scsc_area->general_char,
               sizeof(css_general_characteristics));
        memcpy(&css_chsc_characteristics, scsc_area->chsc_char,
               sizeof(css_chsc_characteristics));
    } else
        CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n",
                      scsc_area->response.code);
exit:
    spin_unlock_irq(&chsc_page_lock);
    return result;
}
Пример #12
0
int chsc_get_channel_measurement_chars(struct channel_path *chp)
{
    struct cmg_chars *cmg_chars;
    int ccode, ret;

    struct {
        struct chsc_header request;
        u32 : 24;
        u32 first_chpid : 8;
        u32 : 24;
        u32 last_chpid : 8;
        u32 zeroes1;
        struct chsc_header response;
        u32 zeroes2;
        u32 not_valid : 1;
        u32 shared : 1;
        u32 : 22;
        u32 chpid : 8;
        u32 cmcv : 5;
        u32 : 11;
        u32 cmgq : 8;
        u32 cmg : 8;
        u32 zeroes3;
        u32 data[NR_MEASUREMENT_CHARS];
    } __attribute__ ((packed)) *scmc_area;

    chp->cmg_chars = NULL;
    cmg_chars = kmalloc(sizeof(*cmg_chars), GFP_KERNEL);
    if (!cmg_chars)
        return -ENOMEM;

    spin_lock_irq(&chsc_page_lock);
    memset(chsc_page, 0, PAGE_SIZE);
    scmc_area = chsc_page;
    scmc_area->request.length = 0x0010;
    scmc_area->request.code = 0x0022;
    scmc_area->first_chpid = chp->chpid.id;
    scmc_area->last_chpid = chp->chpid.id;

    ccode = chsc(scmc_area);
    if (ccode > 0) {
        ret = (ccode == 3) ? -ENODEV : -EBUSY;
        goto out;
    }

    ret = chsc_error_from_response(scmc_area->response.code);
    if (ret) {
        CIO_CRW_EVENT(2, "chsc: scmc failed (rc=%04x)\n",
                      scmc_area->response.code);
        goto out;
    }
    if (scmc_area->not_valid) {
        chp->cmg = -1;
        chp->shared = -1;
        goto out;
    }
    chp->cmg = scmc_area->cmg;
    chp->shared = scmc_area->shared;
    if (chp->cmg != 2 && chp->cmg != 3) {
        /* No cmg-dependent data. */
        goto out;
    }
    chp->cmg_chars = cmg_chars;
    chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
                              (struct cmg_chars *) &scmc_area->data);
out:
    spin_unlock_irq(&chsc_page_lock);
    if (!chp->cmg_chars)
        kfree(cmg_chars);

    return ret;
}