0001
0002
0003
0004
0005
0006
0007 #define KMSG_COMPONENT "sclp_cmd"
0008 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
0009
0010 #include <linux/export.h>
0011 #include <linux/slab.h>
0012 #include <asm/sclp.h>
0013 #include "sclp.h"
0014
0015 #define SCLP_CMDW_CONFIGURE_AP 0x001f0001
0016 #define SCLP_CMDW_DECONFIGURE_AP 0x001e0001
0017
0018 struct ap_cfg_sccb {
0019 struct sccb_header header;
0020 } __packed;
0021
0022 static int do_ap_configure(sclp_cmdw_t cmd, u32 apid)
0023 {
0024 struct ap_cfg_sccb *sccb;
0025 int rc;
0026
0027 if (!SCLP_HAS_AP_RECONFIG)
0028 return -EOPNOTSUPP;
0029
0030 sccb = (struct ap_cfg_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
0031 if (!sccb)
0032 return -ENOMEM;
0033
0034 sccb->header.length = PAGE_SIZE;
0035 cmd |= (apid & 0xFF) << 8;
0036 rc = sclp_sync_request(cmd, sccb);
0037 if (rc)
0038 goto out;
0039 switch (sccb->header.response_code) {
0040 case 0x0020: case 0x0120: case 0x0440: case 0x0450:
0041 break;
0042 default:
0043 pr_warn("configure AP adapter %u failed: cmd=0x%08x response=0x%04x\n",
0044 apid, cmd, sccb->header.response_code);
0045 rc = -EIO;
0046 break;
0047 }
0048 out:
0049 free_page((unsigned long) sccb);
0050 return rc;
0051 }
0052
0053 int sclp_ap_configure(u32 apid)
0054 {
0055 return do_ap_configure(SCLP_CMDW_CONFIGURE_AP, apid);
0056 }
0057 EXPORT_SYMBOL(sclp_ap_configure);
0058
0059 int sclp_ap_deconfigure(u32 apid)
0060 {
0061 return do_ap_configure(SCLP_CMDW_DECONFIGURE_AP, apid);
0062 }
0063 EXPORT_SYMBOL(sclp_ap_deconfigure);