File Index
Files and directories
Sign in
FILE

sclp_ap.c

File preview with syntax highlighting.

linux-6.19.14/drivers/s390/char/sclp_ap.c C
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * s390 crypto adapter related sclp functions.
 4 *
 5 * Copyright IBM Corp. 2020
 6 */
 7#define pr_fmt(fmt) "sclp_cmd: " fmt
 8
 9#include <linux/export.h>
10#include <linux/slab.h>
11#include <asm/sclp.h>
12#include "sclp.h"
13
14#define SCLP_CMDW_CONFIGURE_AP			0x001f0001
15#define SCLP_CMDW_DECONFIGURE_AP		0x001e0001
16
17struct ap_cfg_sccb {
18	struct sccb_header header;
19} __packed;
20
21static int do_ap_configure(sclp_cmdw_t cmd, u32 apid)
22{
23	struct ap_cfg_sccb *sccb;
24	int rc;
25
26	if (!SCLP_HAS_AP_RECONFIG)
27		return -EOPNOTSUPP;
28
29	sccb = (struct ap_cfg_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
30	if (!sccb)
31		return -ENOMEM;
32
33	sccb->header.length = PAGE_SIZE;
34	cmd |= (apid & 0xFF) << 8;
35	rc = sclp_sync_request(cmd, sccb);
36	if (rc)
37		goto out;
38	switch (sccb->header.response_code) {
39	case 0x0020: case 0x0120: case 0x0440: case 0x0450:
40		break;
41	default:
42		pr_warn("configure AP adapter %u failed: cmd=0x%08x response=0x%04x\n",
43			apid, cmd, sccb->header.response_code);
44		rc = -EIO;
45		break;
46	}
47out:
48	free_page((unsigned long) sccb);
49	return rc;
50}
51
52int sclp_ap_configure(u32 apid)
53{
54	return do_ap_configure(SCLP_CMDW_CONFIGURE_AP, apid);
55}
56EXPORT_SYMBOL(sclp_ap_configure);
57
58int sclp_ap_deconfigure(u32 apid)
59{
60	return do_ap_configure(SCLP_CMDW_DECONFIGURE_AP, apid);
61}
62EXPORT_SYMBOL(sclp_ap_deconfigure);
~/ Read-only file preview.