162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright IBM Corp. 2006, 2023 462306a36Sopenharmony_ci * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 562306a36Sopenharmony_ci * Martin Schwidefsky <schwidefsky@de.ibm.com> 662306a36Sopenharmony_ci * Ralph Wuerthner <rwuerthn@de.ibm.com> 762306a36Sopenharmony_ci * Felix Beck <felix.beck@de.ibm.com> 862306a36Sopenharmony_ci * Holger Dengler <hd@linux.vnet.ibm.com> 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci * Adjunct processor bus header file. 1162306a36Sopenharmony_ci */ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#ifndef _AP_BUS_H_ 1462306a36Sopenharmony_ci#define _AP_BUS_H_ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#include <linux/device.h> 1762306a36Sopenharmony_ci#include <linux/types.h> 1862306a36Sopenharmony_ci#include <linux/hashtable.h> 1962306a36Sopenharmony_ci#include <asm/isc.h> 2062306a36Sopenharmony_ci#include <asm/ap.h> 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#define AP_DEVICES 256 /* Number of AP devices. */ 2362306a36Sopenharmony_ci#define AP_DOMAINS 256 /* Number of AP domains. */ 2462306a36Sopenharmony_ci#define AP_IOCTLS 256 /* Number of ioctls. */ 2562306a36Sopenharmony_ci#define AP_RESET_TIMEOUT (HZ*0.7) /* Time in ticks for reset timeouts. */ 2662306a36Sopenharmony_ci#define AP_CONFIG_TIME 30 /* Time in seconds between AP bus rescans. */ 2762306a36Sopenharmony_ci#define AP_POLL_TIME 1 /* Time in ticks between receive polls. */ 2862306a36Sopenharmony_ci#define AP_DEFAULT_MAX_MSG_SIZE (12 * 1024) 2962306a36Sopenharmony_ci#define AP_TAPQ_ML_FIELD_CHUNK_SIZE (4096) 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ciextern int ap_domain_index; 3262306a36Sopenharmony_ciextern atomic_t ap_max_msg_size; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciextern DECLARE_HASHTABLE(ap_queues, 8); 3562306a36Sopenharmony_ciextern spinlock_t ap_queues_lock; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistatic inline int ap_test_bit(unsigned int *ptr, unsigned int nr) 3862306a36Sopenharmony_ci{ 3962306a36Sopenharmony_ci return (*ptr & (0x80000000u >> nr)) != 0; 4062306a36Sopenharmony_ci} 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define AP_RESPONSE_NORMAL 0x00 4362306a36Sopenharmony_ci#define AP_RESPONSE_Q_NOT_AVAIL 0x01 4462306a36Sopenharmony_ci#define AP_RESPONSE_RESET_IN_PROGRESS 0x02 4562306a36Sopenharmony_ci#define AP_RESPONSE_DECONFIGURED 0x03 4662306a36Sopenharmony_ci#define AP_RESPONSE_CHECKSTOPPED 0x04 4762306a36Sopenharmony_ci#define AP_RESPONSE_BUSY 0x05 4862306a36Sopenharmony_ci#define AP_RESPONSE_INVALID_ADDRESS 0x06 4962306a36Sopenharmony_ci#define AP_RESPONSE_OTHERWISE_CHANGED 0x07 5062306a36Sopenharmony_ci#define AP_RESPONSE_INVALID_GISA 0x08 5162306a36Sopenharmony_ci#define AP_RESPONSE_Q_BOUND_TO_ANOTHER 0x09 5262306a36Sopenharmony_ci#define AP_RESPONSE_STATE_CHANGE_IN_PROGRESS 0x0A 5362306a36Sopenharmony_ci#define AP_RESPONSE_Q_NOT_BOUND 0x0B 5462306a36Sopenharmony_ci#define AP_RESPONSE_Q_FULL 0x10 5562306a36Sopenharmony_ci#define AP_RESPONSE_NO_PENDING_REPLY 0x10 5662306a36Sopenharmony_ci#define AP_RESPONSE_INDEX_TOO_BIG 0x11 5762306a36Sopenharmony_ci#define AP_RESPONSE_NO_FIRST_PART 0x13 5862306a36Sopenharmony_ci#define AP_RESPONSE_MESSAGE_TOO_BIG 0x15 5962306a36Sopenharmony_ci#define AP_RESPONSE_REQ_FAC_NOT_INST 0x16 6062306a36Sopenharmony_ci#define AP_RESPONSE_Q_BIND_ERROR 0x30 6162306a36Sopenharmony_ci#define AP_RESPONSE_Q_NOT_AVAIL_FOR_ASSOC 0x31 6262306a36Sopenharmony_ci#define AP_RESPONSE_Q_NOT_EMPTY 0x32 6362306a36Sopenharmony_ci#define AP_RESPONSE_BIND_LIMIT_EXCEEDED 0x33 6462306a36Sopenharmony_ci#define AP_RESPONSE_INVALID_ASSOC_SECRET 0x34 6562306a36Sopenharmony_ci#define AP_RESPONSE_ASSOC_SECRET_NOT_UNIQUE 0x35 6662306a36Sopenharmony_ci#define AP_RESPONSE_ASSOC_FAILED 0x36 6762306a36Sopenharmony_ci#define AP_RESPONSE_INVALID_DOMAIN 0x42 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* 7062306a36Sopenharmony_ci * Supported AP device types 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_ci#define AP_DEVICE_TYPE_CEX4 10 7362306a36Sopenharmony_ci#define AP_DEVICE_TYPE_CEX5 11 7462306a36Sopenharmony_ci#define AP_DEVICE_TYPE_CEX6 12 7562306a36Sopenharmony_ci#define AP_DEVICE_TYPE_CEX7 13 7662306a36Sopenharmony_ci#define AP_DEVICE_TYPE_CEX8 14 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * Known function facilities 8062306a36Sopenharmony_ci */ 8162306a36Sopenharmony_ci#define AP_FUNC_MEX4K 1 8262306a36Sopenharmony_ci#define AP_FUNC_CRT4K 2 8362306a36Sopenharmony_ci#define AP_FUNC_COPRO 3 8462306a36Sopenharmony_ci#define AP_FUNC_ACCEL 4 8562306a36Sopenharmony_ci#define AP_FUNC_EP11 5 8662306a36Sopenharmony_ci#define AP_FUNC_APXA 6 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* 8962306a36Sopenharmony_ci * AP queue state machine states 9062306a36Sopenharmony_ci */ 9162306a36Sopenharmony_cienum ap_sm_state { 9262306a36Sopenharmony_ci AP_SM_STATE_RESET_START = 0, 9362306a36Sopenharmony_ci AP_SM_STATE_RESET_WAIT, 9462306a36Sopenharmony_ci AP_SM_STATE_SETIRQ_WAIT, 9562306a36Sopenharmony_ci AP_SM_STATE_IDLE, 9662306a36Sopenharmony_ci AP_SM_STATE_WORKING, 9762306a36Sopenharmony_ci AP_SM_STATE_QUEUE_FULL, 9862306a36Sopenharmony_ci AP_SM_STATE_ASSOC_WAIT, 9962306a36Sopenharmony_ci NR_AP_SM_STATES 10062306a36Sopenharmony_ci}; 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci/* 10362306a36Sopenharmony_ci * AP queue state machine events 10462306a36Sopenharmony_ci */ 10562306a36Sopenharmony_cienum ap_sm_event { 10662306a36Sopenharmony_ci AP_SM_EVENT_POLL, 10762306a36Sopenharmony_ci AP_SM_EVENT_TIMEOUT, 10862306a36Sopenharmony_ci NR_AP_SM_EVENTS 10962306a36Sopenharmony_ci}; 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci/* 11262306a36Sopenharmony_ci * AP queue state wait behaviour 11362306a36Sopenharmony_ci */ 11462306a36Sopenharmony_cienum ap_sm_wait { 11562306a36Sopenharmony_ci AP_SM_WAIT_AGAIN = 0, /* retry immediately */ 11662306a36Sopenharmony_ci AP_SM_WAIT_HIGH_TIMEOUT, /* poll high freq, wait for timeout */ 11762306a36Sopenharmony_ci AP_SM_WAIT_LOW_TIMEOUT, /* poll low freq, wait for timeout */ 11862306a36Sopenharmony_ci AP_SM_WAIT_INTERRUPT, /* wait for thin interrupt (if available) */ 11962306a36Sopenharmony_ci AP_SM_WAIT_NONE, /* no wait */ 12062306a36Sopenharmony_ci NR_AP_SM_WAIT 12162306a36Sopenharmony_ci}; 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci/* 12462306a36Sopenharmony_ci * AP queue device states 12562306a36Sopenharmony_ci */ 12662306a36Sopenharmony_cienum ap_dev_state { 12762306a36Sopenharmony_ci AP_DEV_STATE_UNINITIATED = 0, /* fresh and virgin, not touched */ 12862306a36Sopenharmony_ci AP_DEV_STATE_OPERATING, /* queue dev is working normal */ 12962306a36Sopenharmony_ci AP_DEV_STATE_SHUTDOWN, /* remove/unbind/shutdown in progress */ 13062306a36Sopenharmony_ci AP_DEV_STATE_ERROR, /* device is in error state */ 13162306a36Sopenharmony_ci NR_AP_DEV_STATES 13262306a36Sopenharmony_ci}; 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_cistruct ap_device; 13562306a36Sopenharmony_cistruct ap_message; 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/* 13862306a36Sopenharmony_ci * The ap driver struct includes a flags field which holds some info for 13962306a36Sopenharmony_ci * the ap bus about the driver. Currently only one flag is supported and 14062306a36Sopenharmony_ci * used: The DEFAULT flag marks an ap driver as a default driver which is 14162306a36Sopenharmony_ci * used together with the apmask and aqmask whitelisting of the ap bus. 14262306a36Sopenharmony_ci */ 14362306a36Sopenharmony_ci#define AP_DRIVER_FLAG_DEFAULT 0x0001 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cistruct ap_driver { 14662306a36Sopenharmony_ci struct device_driver driver; 14762306a36Sopenharmony_ci struct ap_device_id *ids; 14862306a36Sopenharmony_ci unsigned int flags; 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci int (*probe)(struct ap_device *); 15162306a36Sopenharmony_ci void (*remove)(struct ap_device *); 15262306a36Sopenharmony_ci int (*in_use)(unsigned long *apm, unsigned long *aqm); 15362306a36Sopenharmony_ci /* 15462306a36Sopenharmony_ci * Called at the start of the ap bus scan function when 15562306a36Sopenharmony_ci * the crypto config information (qci) has changed. 15662306a36Sopenharmony_ci * This callback is not invoked if there is no AP 15762306a36Sopenharmony_ci * QCI support available. 15862306a36Sopenharmony_ci */ 15962306a36Sopenharmony_ci void (*on_config_changed)(struct ap_config_info *new_config_info, 16062306a36Sopenharmony_ci struct ap_config_info *old_config_info); 16162306a36Sopenharmony_ci /* 16262306a36Sopenharmony_ci * Called at the end of the ap bus scan function when 16362306a36Sopenharmony_ci * the crypto config information (qci) has changed. 16462306a36Sopenharmony_ci * This callback is not invoked if there is no AP 16562306a36Sopenharmony_ci * QCI support available. 16662306a36Sopenharmony_ci */ 16762306a36Sopenharmony_ci void (*on_scan_complete)(struct ap_config_info *new_config_info, 16862306a36Sopenharmony_ci struct ap_config_info *old_config_info); 16962306a36Sopenharmony_ci}; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#define to_ap_drv(x) container_of((x), struct ap_driver, driver) 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ciint ap_driver_register(struct ap_driver *, struct module *, char *); 17462306a36Sopenharmony_civoid ap_driver_unregister(struct ap_driver *); 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_cistruct ap_device { 17762306a36Sopenharmony_ci struct device device; 17862306a36Sopenharmony_ci int device_type; /* AP device type. */ 17962306a36Sopenharmony_ci}; 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci#define to_ap_dev(x) container_of((x), struct ap_device, device) 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_cistruct ap_card { 18462306a36Sopenharmony_ci struct ap_device ap_dev; 18562306a36Sopenharmony_ci int raw_hwtype; /* AP raw hardware type. */ 18662306a36Sopenharmony_ci unsigned int functions; /* TAPQ GR2 upper 32 facility bits */ 18762306a36Sopenharmony_ci int queue_depth; /* AP queue depth.*/ 18862306a36Sopenharmony_ci int id; /* AP card number. */ 18962306a36Sopenharmony_ci unsigned int maxmsgsize; /* AP msg limit for this card */ 19062306a36Sopenharmony_ci bool config; /* configured state */ 19162306a36Sopenharmony_ci bool chkstop; /* checkstop state */ 19262306a36Sopenharmony_ci atomic64_t total_request_count; /* # requests ever for this AP device.*/ 19362306a36Sopenharmony_ci}; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#define TAPQ_CARD_FUNC_CMP_MASK 0xFFFF0000 19662306a36Sopenharmony_ci#define ASSOC_IDX_INVALID 0x10000 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci#define to_ap_card(x) container_of((x), struct ap_card, ap_dev.device) 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_cistruct ap_queue { 20162306a36Sopenharmony_ci struct ap_device ap_dev; 20262306a36Sopenharmony_ci struct hlist_node hnode; /* Node for the ap_queues hashtable */ 20362306a36Sopenharmony_ci struct ap_card *card; /* Ptr to assoc. AP card. */ 20462306a36Sopenharmony_ci spinlock_t lock; /* Per device lock. */ 20562306a36Sopenharmony_ci enum ap_dev_state dev_state; /* queue device state */ 20662306a36Sopenharmony_ci bool config; /* configured state */ 20762306a36Sopenharmony_ci bool chkstop; /* checkstop state */ 20862306a36Sopenharmony_ci ap_qid_t qid; /* AP queue id. */ 20962306a36Sopenharmony_ci bool interrupt; /* indicate if interrupts are enabled */ 21062306a36Sopenharmony_ci unsigned int assoc_idx; /* SE association index */ 21162306a36Sopenharmony_ci int queue_count; /* # messages currently on AP queue. */ 21262306a36Sopenharmony_ci int pendingq_count; /* # requests on pendingq list. */ 21362306a36Sopenharmony_ci int requestq_count; /* # requests on requestq list. */ 21462306a36Sopenharmony_ci u64 total_request_count; /* # requests ever for this AP device.*/ 21562306a36Sopenharmony_ci int request_timeout; /* Request timeout in jiffies. */ 21662306a36Sopenharmony_ci struct timer_list timeout; /* Timer for request timeouts. */ 21762306a36Sopenharmony_ci struct list_head pendingq; /* List of message sent to AP queue. */ 21862306a36Sopenharmony_ci struct list_head requestq; /* List of message yet to be sent. */ 21962306a36Sopenharmony_ci struct ap_message *reply; /* Per device reply message. */ 22062306a36Sopenharmony_ci enum ap_sm_state sm_state; /* ap queue state machine state */ 22162306a36Sopenharmony_ci int rapq_fbit; /* fbit arg for next rapq invocation */ 22262306a36Sopenharmony_ci int last_err_rc; /* last error state response code */ 22362306a36Sopenharmony_ci}; 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci#define to_ap_queue(x) container_of((x), struct ap_queue, ap_dev.device) 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_citypedef enum ap_sm_wait (ap_func_t)(struct ap_queue *queue); 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_cistruct ap_message { 23062306a36Sopenharmony_ci struct list_head list; /* Request queueing. */ 23162306a36Sopenharmony_ci unsigned long psmid; /* Message id. */ 23262306a36Sopenharmony_ci void *msg; /* Pointer to message buffer. */ 23362306a36Sopenharmony_ci size_t len; /* actual msg len in msg buffer */ 23462306a36Sopenharmony_ci size_t bufsize; /* allocated msg buffer size */ 23562306a36Sopenharmony_ci u16 flags; /* Flags, see AP_MSG_FLAG_xxx */ 23662306a36Sopenharmony_ci int rc; /* Return code for this message */ 23762306a36Sopenharmony_ci void *private; /* ap driver private pointer. */ 23862306a36Sopenharmony_ci /* receive is called from tasklet context */ 23962306a36Sopenharmony_ci void (*receive)(struct ap_queue *, struct ap_message *, 24062306a36Sopenharmony_ci struct ap_message *); 24162306a36Sopenharmony_ci}; 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci#define AP_MSG_FLAG_SPECIAL 0x0001 /* flag msg as 'special' with NQAP */ 24462306a36Sopenharmony_ci#define AP_MSG_FLAG_USAGE 0x0002 /* CCA, EP11: usage (no admin) msg */ 24562306a36Sopenharmony_ci#define AP_MSG_FLAG_ADMIN 0x0004 /* CCA, EP11: admin (=control) msg */ 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci/** 24862306a36Sopenharmony_ci * ap_init_message() - Initialize ap_message. 24962306a36Sopenharmony_ci * Initialize a message before using. Otherwise this might result in 25062306a36Sopenharmony_ci * unexpected behaviour. 25162306a36Sopenharmony_ci */ 25262306a36Sopenharmony_cistatic inline void ap_init_message(struct ap_message *ap_msg) 25362306a36Sopenharmony_ci{ 25462306a36Sopenharmony_ci memset(ap_msg, 0, sizeof(*ap_msg)); 25562306a36Sopenharmony_ci} 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci/** 25862306a36Sopenharmony_ci * ap_release_message() - Release ap_message. 25962306a36Sopenharmony_ci * Releases all memory used internal within the ap_message struct 26062306a36Sopenharmony_ci * Currently this is the message and private field. 26162306a36Sopenharmony_ci */ 26262306a36Sopenharmony_cistatic inline void ap_release_message(struct ap_message *ap_msg) 26362306a36Sopenharmony_ci{ 26462306a36Sopenharmony_ci kfree_sensitive(ap_msg->msg); 26562306a36Sopenharmony_ci kfree_sensitive(ap_msg->private); 26662306a36Sopenharmony_ci} 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_cienum ap_sm_wait ap_sm_event(struct ap_queue *aq, enum ap_sm_event event); 26962306a36Sopenharmony_cienum ap_sm_wait ap_sm_event_loop(struct ap_queue *aq, enum ap_sm_event event); 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ciint ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg); 27262306a36Sopenharmony_civoid ap_cancel_message(struct ap_queue *aq, struct ap_message *ap_msg); 27362306a36Sopenharmony_civoid ap_flush_queue(struct ap_queue *aq); 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_civoid *ap_airq_ptr(void); 27662306a36Sopenharmony_ciint ap_sb_available(void); 27762306a36Sopenharmony_cibool ap_is_se_guest(void); 27862306a36Sopenharmony_civoid ap_wait(enum ap_sm_wait wait); 27962306a36Sopenharmony_civoid ap_request_timeout(struct timer_list *t); 28062306a36Sopenharmony_civoid ap_bus_force_rescan(void); 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ciint ap_test_config_usage_domain(unsigned int domain); 28362306a36Sopenharmony_ciint ap_test_config_ctrl_domain(unsigned int domain); 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_civoid ap_queue_init_reply(struct ap_queue *aq, struct ap_message *ap_msg); 28662306a36Sopenharmony_cistruct ap_queue *ap_queue_create(ap_qid_t qid, int device_type); 28762306a36Sopenharmony_civoid ap_queue_prepare_remove(struct ap_queue *aq); 28862306a36Sopenharmony_civoid ap_queue_remove(struct ap_queue *aq); 28962306a36Sopenharmony_civoid ap_queue_init_state(struct ap_queue *aq); 29062306a36Sopenharmony_civoid _ap_queue_init_state(struct ap_queue *aq); 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_cistruct ap_card *ap_card_create(int id, int queue_depth, int raw_type, 29362306a36Sopenharmony_ci int comp_type, unsigned int functions, int ml); 29462306a36Sopenharmony_ci 29562306a36Sopenharmony_ci#define APMASKSIZE (BITS_TO_LONGS(AP_DEVICES) * sizeof(unsigned long)) 29662306a36Sopenharmony_ci#define AQMASKSIZE (BITS_TO_LONGS(AP_DOMAINS) * sizeof(unsigned long)) 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_cistruct ap_perms { 29962306a36Sopenharmony_ci unsigned long ioctlm[BITS_TO_LONGS(AP_IOCTLS)]; 30062306a36Sopenharmony_ci unsigned long apm[BITS_TO_LONGS(AP_DEVICES)]; 30162306a36Sopenharmony_ci unsigned long aqm[BITS_TO_LONGS(AP_DOMAINS)]; 30262306a36Sopenharmony_ci unsigned long adm[BITS_TO_LONGS(AP_DOMAINS)]; 30362306a36Sopenharmony_ci}; 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ciextern struct ap_perms ap_perms; 30662306a36Sopenharmony_ciextern struct mutex ap_perms_mutex; 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci/* 30962306a36Sopenharmony_ci * Get ap_queue device for this qid. 31062306a36Sopenharmony_ci * Returns ptr to the struct ap_queue device or NULL if there 31162306a36Sopenharmony_ci * was no ap_queue device with this qid found. When something is 31262306a36Sopenharmony_ci * found, the reference count of the embedded device is increased. 31362306a36Sopenharmony_ci * So the caller has to decrease the reference count after use 31462306a36Sopenharmony_ci * with a call to put_device(&aq->ap_dev.device). 31562306a36Sopenharmony_ci */ 31662306a36Sopenharmony_cistruct ap_queue *ap_get_qdev(ap_qid_t qid); 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ci/* 31962306a36Sopenharmony_ci * check APQN for owned/reserved by ap bus and default driver(s). 32062306a36Sopenharmony_ci * Checks if this APQN is or will be in use by the ap bus 32162306a36Sopenharmony_ci * and the default set of drivers. 32262306a36Sopenharmony_ci * If yes, returns 1, if not returns 0. On error a negative 32362306a36Sopenharmony_ci * errno value is returned. 32462306a36Sopenharmony_ci */ 32562306a36Sopenharmony_ciint ap_owned_by_def_drv(int card, int queue); 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci/* 32862306a36Sopenharmony_ci * check 'matrix' of APQNs for owned/reserved by ap bus and 32962306a36Sopenharmony_ci * default driver(s). 33062306a36Sopenharmony_ci * Checks if there is at least one APQN in the given 'matrix' 33162306a36Sopenharmony_ci * marked as owned/reserved by the ap bus and default driver(s). 33262306a36Sopenharmony_ci * If such an APQN is found the return value is 1, otherwise 33362306a36Sopenharmony_ci * 0 is returned. On error a negative errno value is returned. 33462306a36Sopenharmony_ci * The parameter apm is a bitmask which should be declared 33562306a36Sopenharmony_ci * as DECLARE_BITMAP(apm, AP_DEVICES), the aqm parameter is 33662306a36Sopenharmony_ci * similar, should be declared as DECLARE_BITMAP(aqm, AP_DOMAINS). 33762306a36Sopenharmony_ci */ 33862306a36Sopenharmony_ciint ap_apqn_in_matrix_owned_by_def_drv(unsigned long *apm, 33962306a36Sopenharmony_ci unsigned long *aqm); 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci/* 34262306a36Sopenharmony_ci * ap_parse_mask_str() - helper function to parse a bitmap string 34362306a36Sopenharmony_ci * and clear/set the bits in the bitmap accordingly. The string may be 34462306a36Sopenharmony_ci * given as absolute value, a hex string like 0x1F2E3D4C5B6A" simple 34562306a36Sopenharmony_ci * overwriting the current content of the bitmap. Or as relative string 34662306a36Sopenharmony_ci * like "+1-16,-32,-0x40,+128" where only single bits or ranges of 34762306a36Sopenharmony_ci * bits are cleared or set. Distinction is done based on the very 34862306a36Sopenharmony_ci * first character which may be '+' or '-' for the relative string 34962306a36Sopenharmony_ci * and otherwise assume to be an absolute value string. If parsing fails 35062306a36Sopenharmony_ci * a negative errno value is returned. All arguments and bitmaps are 35162306a36Sopenharmony_ci * big endian order. 35262306a36Sopenharmony_ci */ 35362306a36Sopenharmony_ciint ap_parse_mask_str(const char *str, 35462306a36Sopenharmony_ci unsigned long *bitmap, int bits, 35562306a36Sopenharmony_ci struct mutex *lock); 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci/* 35862306a36Sopenharmony_ci * Interface to wait for the AP bus to have done one initial ap bus 35962306a36Sopenharmony_ci * scan and all detected APQNs have been bound to device drivers. 36062306a36Sopenharmony_ci * If these both conditions are not fulfilled, this function blocks 36162306a36Sopenharmony_ci * on a condition with wait_for_completion_killable_timeout(). 36262306a36Sopenharmony_ci * If these both conditions are fulfilled (before the timeout hits) 36362306a36Sopenharmony_ci * the return value is 0. If the timeout (in jiffies) hits instead 36462306a36Sopenharmony_ci * -ETIME is returned. On failures negative return values are 36562306a36Sopenharmony_ci * returned to the caller. 36662306a36Sopenharmony_ci */ 36762306a36Sopenharmony_ciint ap_wait_init_apqn_bindings_complete(unsigned long timeout); 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_civoid ap_send_config_uevent(struct ap_device *ap_dev, bool cfg); 37062306a36Sopenharmony_civoid ap_send_online_uevent(struct ap_device *ap_dev, int online); 37162306a36Sopenharmony_ci 37262306a36Sopenharmony_ci#endif /* _AP_BUS_H_ */ 373