xref: /OK3568_Linux_fs/kernel/drivers/s390/crypto/ap_bus.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright IBM Corp. 2006, 2019
4*4882a593Smuzhiyun  * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
5*4882a593Smuzhiyun  *	      Martin Schwidefsky <schwidefsky@de.ibm.com>
6*4882a593Smuzhiyun  *	      Ralph Wuerthner <rwuerthn@de.ibm.com>
7*4882a593Smuzhiyun  *	      Felix Beck <felix.beck@de.ibm.com>
8*4882a593Smuzhiyun  *	      Holger Dengler <hd@linux.vnet.ibm.com>
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Adjunct processor bus header file.
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #ifndef _AP_BUS_H_
14*4882a593Smuzhiyun #define _AP_BUS_H_
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #include <linux/device.h>
17*4882a593Smuzhiyun #include <linux/types.h>
18*4882a593Smuzhiyun #include <linux/hashtable.h>
19*4882a593Smuzhiyun #include <asm/isc.h>
20*4882a593Smuzhiyun #include <asm/ap.h>
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #define AP_DEVICES 256		/* Number of AP devices. */
23*4882a593Smuzhiyun #define AP_DOMAINS 256		/* Number of AP domains. */
24*4882a593Smuzhiyun #define AP_IOCTLS  256		/* Number of ioctls. */
25*4882a593Smuzhiyun #define AP_RESET_TIMEOUT (HZ*0.7)	/* Time in ticks for reset timeouts. */
26*4882a593Smuzhiyun #define AP_CONFIG_TIME 30	/* Time in seconds between AP bus rescans. */
27*4882a593Smuzhiyun #define AP_POLL_TIME 1		/* Time in ticks between receive polls. */
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun extern int ap_domain_index;
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun extern DECLARE_HASHTABLE(ap_queues, 8);
32*4882a593Smuzhiyun extern spinlock_t ap_queues_lock;
33*4882a593Smuzhiyun 
ap_test_bit(unsigned int * ptr,unsigned int nr)34*4882a593Smuzhiyun static inline int ap_test_bit(unsigned int *ptr, unsigned int nr)
35*4882a593Smuzhiyun {
36*4882a593Smuzhiyun 	return (*ptr & (0x80000000u >> nr)) != 0;
37*4882a593Smuzhiyun }
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #define AP_RESPONSE_NORMAL		0x00
40*4882a593Smuzhiyun #define AP_RESPONSE_Q_NOT_AVAIL		0x01
41*4882a593Smuzhiyun #define AP_RESPONSE_RESET_IN_PROGRESS	0x02
42*4882a593Smuzhiyun #define AP_RESPONSE_DECONFIGURED	0x03
43*4882a593Smuzhiyun #define AP_RESPONSE_CHECKSTOPPED	0x04
44*4882a593Smuzhiyun #define AP_RESPONSE_BUSY		0x05
45*4882a593Smuzhiyun #define AP_RESPONSE_INVALID_ADDRESS	0x06
46*4882a593Smuzhiyun #define AP_RESPONSE_OTHERWISE_CHANGED	0x07
47*4882a593Smuzhiyun #define AP_RESPONSE_Q_FULL		0x10
48*4882a593Smuzhiyun #define AP_RESPONSE_NO_PENDING_REPLY	0x10
49*4882a593Smuzhiyun #define AP_RESPONSE_INDEX_TOO_BIG	0x11
50*4882a593Smuzhiyun #define AP_RESPONSE_NO_FIRST_PART	0x13
51*4882a593Smuzhiyun #define AP_RESPONSE_MESSAGE_TOO_BIG	0x15
52*4882a593Smuzhiyun #define AP_RESPONSE_REQ_FAC_NOT_INST	0x16
53*4882a593Smuzhiyun #define AP_RESPONSE_INVALID_DOMAIN	0x42
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun /*
56*4882a593Smuzhiyun  * Known device types
57*4882a593Smuzhiyun  */
58*4882a593Smuzhiyun #define AP_DEVICE_TYPE_PCICC	3
59*4882a593Smuzhiyun #define AP_DEVICE_TYPE_PCICA	4
60*4882a593Smuzhiyun #define AP_DEVICE_TYPE_PCIXCC	5
61*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX2A	6
62*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX2C	7
63*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX3A	8
64*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX3C	9
65*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX4	10
66*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX5	11
67*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX6	12
68*4882a593Smuzhiyun #define AP_DEVICE_TYPE_CEX7	13
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun /*
71*4882a593Smuzhiyun  * Known function facilities
72*4882a593Smuzhiyun  */
73*4882a593Smuzhiyun #define AP_FUNC_MEX4K 1
74*4882a593Smuzhiyun #define AP_FUNC_CRT4K 2
75*4882a593Smuzhiyun #define AP_FUNC_COPRO 3
76*4882a593Smuzhiyun #define AP_FUNC_ACCEL 4
77*4882a593Smuzhiyun #define AP_FUNC_EP11  5
78*4882a593Smuzhiyun #define AP_FUNC_APXA  6
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun /*
81*4882a593Smuzhiyun  * AP queue state machine states
82*4882a593Smuzhiyun  */
83*4882a593Smuzhiyun enum ap_sm_state {
84*4882a593Smuzhiyun 	AP_SM_STATE_RESET_START = 0,
85*4882a593Smuzhiyun 	AP_SM_STATE_RESET_WAIT,
86*4882a593Smuzhiyun 	AP_SM_STATE_SETIRQ_WAIT,
87*4882a593Smuzhiyun 	AP_SM_STATE_IDLE,
88*4882a593Smuzhiyun 	AP_SM_STATE_WORKING,
89*4882a593Smuzhiyun 	AP_SM_STATE_QUEUE_FULL,
90*4882a593Smuzhiyun 	NR_AP_SM_STATES
91*4882a593Smuzhiyun };
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun /*
94*4882a593Smuzhiyun  * AP queue state machine events
95*4882a593Smuzhiyun  */
96*4882a593Smuzhiyun enum ap_sm_event {
97*4882a593Smuzhiyun 	AP_SM_EVENT_POLL,
98*4882a593Smuzhiyun 	AP_SM_EVENT_TIMEOUT,
99*4882a593Smuzhiyun 	NR_AP_SM_EVENTS
100*4882a593Smuzhiyun };
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun /*
103*4882a593Smuzhiyun  * AP queue state wait behaviour
104*4882a593Smuzhiyun  */
105*4882a593Smuzhiyun enum ap_sm_wait {
106*4882a593Smuzhiyun 	AP_SM_WAIT_AGAIN = 0,	/* retry immediately */
107*4882a593Smuzhiyun 	AP_SM_WAIT_TIMEOUT,	/* wait for timeout */
108*4882a593Smuzhiyun 	AP_SM_WAIT_INTERRUPT,	/* wait for thin interrupt (if available) */
109*4882a593Smuzhiyun 	AP_SM_WAIT_NONE,	/* no wait */
110*4882a593Smuzhiyun 	NR_AP_SM_WAIT
111*4882a593Smuzhiyun };
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun /*
114*4882a593Smuzhiyun  * AP queue device states
115*4882a593Smuzhiyun  */
116*4882a593Smuzhiyun enum ap_dev_state {
117*4882a593Smuzhiyun 	AP_DEV_STATE_UNINITIATED = 0,	/* fresh and virgin, not touched */
118*4882a593Smuzhiyun 	AP_DEV_STATE_OPERATING,		/* queue dev is working normal */
119*4882a593Smuzhiyun 	AP_DEV_STATE_SHUTDOWN,		/* remove/unbind/shutdown in progress */
120*4882a593Smuzhiyun 	AP_DEV_STATE_ERROR,		/* device is in error state */
121*4882a593Smuzhiyun 	NR_AP_DEV_STATES
122*4882a593Smuzhiyun };
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun struct ap_device;
125*4882a593Smuzhiyun struct ap_message;
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun /*
128*4882a593Smuzhiyun  * The ap driver struct includes a flags field which holds some info for
129*4882a593Smuzhiyun  * the ap bus about the driver. Currently only one flag is supported and
130*4882a593Smuzhiyun  * used: The DEFAULT flag marks an ap driver as a default driver which is
131*4882a593Smuzhiyun  * used together with the apmask and aqmask whitelisting of the ap bus.
132*4882a593Smuzhiyun  */
133*4882a593Smuzhiyun #define AP_DRIVER_FLAG_DEFAULT 0x0001
134*4882a593Smuzhiyun 
135*4882a593Smuzhiyun struct ap_driver {
136*4882a593Smuzhiyun 	struct device_driver driver;
137*4882a593Smuzhiyun 	struct ap_device_id *ids;
138*4882a593Smuzhiyun 	unsigned int flags;
139*4882a593Smuzhiyun 
140*4882a593Smuzhiyun 	int (*probe)(struct ap_device *);
141*4882a593Smuzhiyun 	void (*remove)(struct ap_device *);
142*4882a593Smuzhiyun };
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun #define to_ap_drv(x) container_of((x), struct ap_driver, driver)
145*4882a593Smuzhiyun 
146*4882a593Smuzhiyun int ap_driver_register(struct ap_driver *, struct module *, char *);
147*4882a593Smuzhiyun void ap_driver_unregister(struct ap_driver *);
148*4882a593Smuzhiyun 
149*4882a593Smuzhiyun struct ap_device {
150*4882a593Smuzhiyun 	struct device device;
151*4882a593Smuzhiyun 	struct ap_driver *drv;		/* Pointer to AP device driver. */
152*4882a593Smuzhiyun 	int device_type;		/* AP device type. */
153*4882a593Smuzhiyun };
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun #define to_ap_dev(x) container_of((x), struct ap_device, device)
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun struct ap_card {
158*4882a593Smuzhiyun 	struct ap_device ap_dev;
159*4882a593Smuzhiyun 	void *private;			/* ap driver private pointer. */
160*4882a593Smuzhiyun 	int raw_hwtype;			/* AP raw hardware type. */
161*4882a593Smuzhiyun 	unsigned int functions;		/* AP device function bitfield. */
162*4882a593Smuzhiyun 	int queue_depth;		/* AP queue depth.*/
163*4882a593Smuzhiyun 	int id;				/* AP card number. */
164*4882a593Smuzhiyun 	bool config;			/* configured state */
165*4882a593Smuzhiyun 	atomic64_t total_request_count;	/* # requests ever for this AP device.*/
166*4882a593Smuzhiyun };
167*4882a593Smuzhiyun 
168*4882a593Smuzhiyun #define to_ap_card(x) container_of((x), struct ap_card, ap_dev.device)
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun struct ap_queue {
171*4882a593Smuzhiyun 	struct ap_device ap_dev;
172*4882a593Smuzhiyun 	struct hlist_node hnode;	/* Node for the ap_queues hashtable */
173*4882a593Smuzhiyun 	struct ap_card *card;		/* Ptr to assoc. AP card. */
174*4882a593Smuzhiyun 	spinlock_t lock;		/* Per device lock. */
175*4882a593Smuzhiyun 	void *private;			/* ap driver private pointer. */
176*4882a593Smuzhiyun 	enum ap_dev_state dev_state;	/* queue device state */
177*4882a593Smuzhiyun 	bool config;			/* configured state */
178*4882a593Smuzhiyun 	ap_qid_t qid;			/* AP queue id. */
179*4882a593Smuzhiyun 	bool interrupt;			/* indicate if interrupts are enabled */
180*4882a593Smuzhiyun 	int queue_count;		/* # messages currently on AP queue. */
181*4882a593Smuzhiyun 	int pendingq_count;		/* # requests on pendingq list. */
182*4882a593Smuzhiyun 	int requestq_count;		/* # requests on requestq list. */
183*4882a593Smuzhiyun 	u64 total_request_count;	/* # requests ever for this AP device.*/
184*4882a593Smuzhiyun 	int request_timeout;		/* Request timeout in jiffies. */
185*4882a593Smuzhiyun 	struct timer_list timeout;	/* Timer for request timeouts. */
186*4882a593Smuzhiyun 	struct list_head pendingq;	/* List of message sent to AP queue. */
187*4882a593Smuzhiyun 	struct list_head requestq;	/* List of message yet to be sent. */
188*4882a593Smuzhiyun 	struct ap_message *reply;	/* Per device reply message. */
189*4882a593Smuzhiyun 	enum ap_sm_state sm_state;	/* ap queue state machine state */
190*4882a593Smuzhiyun 	int last_err_rc;		/* last error state response code */
191*4882a593Smuzhiyun };
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun #define to_ap_queue(x) container_of((x), struct ap_queue, ap_dev.device)
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun typedef enum ap_sm_wait (ap_func_t)(struct ap_queue *queue);
196*4882a593Smuzhiyun 
197*4882a593Smuzhiyun /* failure injection cmd struct */
198*4882a593Smuzhiyun struct ap_fi {
199*4882a593Smuzhiyun 	union {
200*4882a593Smuzhiyun 		u16 cmd;		/* fi flags + action */
201*4882a593Smuzhiyun 		struct {
202*4882a593Smuzhiyun 			u8 flags;	/* fi flags only */
203*4882a593Smuzhiyun 			u8 action;	/* fi action only */
204*4882a593Smuzhiyun 		};
205*4882a593Smuzhiyun 	};
206*4882a593Smuzhiyun };
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun /* all currently known fi actions */
209*4882a593Smuzhiyun enum ap_fi_actions {
210*4882a593Smuzhiyun 	AP_FI_ACTION_CCA_AGENT_FF   = 0x01,
211*4882a593Smuzhiyun 	AP_FI_ACTION_CCA_DOM_INVAL  = 0x02,
212*4882a593Smuzhiyun 	AP_FI_ACTION_NQAP_QID_INVAL = 0x03,
213*4882a593Smuzhiyun };
214*4882a593Smuzhiyun 
215*4882a593Smuzhiyun /* all currently known fi flags */
216*4882a593Smuzhiyun enum ap_fi_flags {
217*4882a593Smuzhiyun 	AP_FI_FLAG_NO_RETRY	  = 0x01,
218*4882a593Smuzhiyun 	AP_FI_FLAG_TOGGLE_SPECIAL = 0x02,
219*4882a593Smuzhiyun };
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun struct ap_message {
222*4882a593Smuzhiyun 	struct list_head list;		/* Request queueing. */
223*4882a593Smuzhiyun 	unsigned long long psmid;	/* Message id. */
224*4882a593Smuzhiyun 	void *msg;			/* Pointer to message buffer. */
225*4882a593Smuzhiyun 	unsigned int len;		/* Message length. */
226*4882a593Smuzhiyun 	u16 flags;			/* Flags, see AP_MSG_FLAG_xxx */
227*4882a593Smuzhiyun 	struct ap_fi fi;		/* Failure Injection cmd */
228*4882a593Smuzhiyun 	int rc;				/* Return code for this message */
229*4882a593Smuzhiyun 	void *private;			/* ap driver private pointer. */
230*4882a593Smuzhiyun 	/* receive is called from tasklet context */
231*4882a593Smuzhiyun 	void (*receive)(struct ap_queue *, struct ap_message *,
232*4882a593Smuzhiyun 			struct ap_message *);
233*4882a593Smuzhiyun };
234*4882a593Smuzhiyun 
235*4882a593Smuzhiyun #define AP_MSG_FLAG_SPECIAL  1		/* flag msg as 'special' with NQAP */
236*4882a593Smuzhiyun 
237*4882a593Smuzhiyun /**
238*4882a593Smuzhiyun  * ap_init_message() - Initialize ap_message.
239*4882a593Smuzhiyun  * Initialize a message before using. Otherwise this might result in
240*4882a593Smuzhiyun  * unexpected behaviour.
241*4882a593Smuzhiyun  */
ap_init_message(struct ap_message * ap_msg)242*4882a593Smuzhiyun static inline void ap_init_message(struct ap_message *ap_msg)
243*4882a593Smuzhiyun {
244*4882a593Smuzhiyun 	memset(ap_msg, 0, sizeof(*ap_msg));
245*4882a593Smuzhiyun }
246*4882a593Smuzhiyun 
247*4882a593Smuzhiyun /**
248*4882a593Smuzhiyun  * ap_release_message() - Release ap_message.
249*4882a593Smuzhiyun  * Releases all memory used internal within the ap_message struct
250*4882a593Smuzhiyun  * Currently this is the message and private field.
251*4882a593Smuzhiyun  */
ap_release_message(struct ap_message * ap_msg)252*4882a593Smuzhiyun static inline void ap_release_message(struct ap_message *ap_msg)
253*4882a593Smuzhiyun {
254*4882a593Smuzhiyun 	kfree_sensitive(ap_msg->msg);
255*4882a593Smuzhiyun 	kfree_sensitive(ap_msg->private);
256*4882a593Smuzhiyun }
257*4882a593Smuzhiyun 
258*4882a593Smuzhiyun /*
259*4882a593Smuzhiyun  * Note: don't use ap_send/ap_recv after using ap_queue_message
260*4882a593Smuzhiyun  * for the first time. Otherwise the ap message queue will get
261*4882a593Smuzhiyun  * confused.
262*4882a593Smuzhiyun  */
263*4882a593Smuzhiyun int ap_send(ap_qid_t, unsigned long long, void *, size_t);
264*4882a593Smuzhiyun int ap_recv(ap_qid_t, unsigned long long *, void *, size_t);
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun enum ap_sm_wait ap_sm_event(struct ap_queue *aq, enum ap_sm_event event);
267*4882a593Smuzhiyun enum ap_sm_wait ap_sm_event_loop(struct ap_queue *aq, enum ap_sm_event event);
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun int ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg);
270*4882a593Smuzhiyun void ap_cancel_message(struct ap_queue *aq, struct ap_message *ap_msg);
271*4882a593Smuzhiyun void ap_flush_queue(struct ap_queue *aq);
272*4882a593Smuzhiyun 
273*4882a593Smuzhiyun void *ap_airq_ptr(void);
274*4882a593Smuzhiyun void ap_wait(enum ap_sm_wait wait);
275*4882a593Smuzhiyun void ap_request_timeout(struct timer_list *t);
276*4882a593Smuzhiyun void ap_bus_force_rescan(void);
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun int ap_test_config_usage_domain(unsigned int domain);
279*4882a593Smuzhiyun int ap_test_config_ctrl_domain(unsigned int domain);
280*4882a593Smuzhiyun 
281*4882a593Smuzhiyun void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *ap_msg);
282*4882a593Smuzhiyun struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type);
283*4882a593Smuzhiyun void ap_queue_prepare_remove(struct ap_queue *aq);
284*4882a593Smuzhiyun void ap_queue_remove(struct ap_queue *aq);
285*4882a593Smuzhiyun void ap_queue_init_state(struct ap_queue *aq);
286*4882a593Smuzhiyun 
287*4882a593Smuzhiyun struct ap_card *ap_card_create(int id, int queue_depth, int raw_device_type,
288*4882a593Smuzhiyun 			       int comp_device_type, unsigned int functions);
289*4882a593Smuzhiyun 
290*4882a593Smuzhiyun struct ap_perms {
291*4882a593Smuzhiyun 	unsigned long ioctlm[BITS_TO_LONGS(AP_IOCTLS)];
292*4882a593Smuzhiyun 	unsigned long apm[BITS_TO_LONGS(AP_DEVICES)];
293*4882a593Smuzhiyun 	unsigned long aqm[BITS_TO_LONGS(AP_DOMAINS)];
294*4882a593Smuzhiyun };
295*4882a593Smuzhiyun extern struct ap_perms ap_perms;
296*4882a593Smuzhiyun extern struct mutex ap_perms_mutex;
297*4882a593Smuzhiyun 
298*4882a593Smuzhiyun /*
299*4882a593Smuzhiyun  * Get ap_queue device for this qid.
300*4882a593Smuzhiyun  * Returns ptr to the struct ap_queue device or NULL if there
301*4882a593Smuzhiyun  * was no ap_queue device with this qid found. When something is
302*4882a593Smuzhiyun  * found, the reference count of the embedded device is increased.
303*4882a593Smuzhiyun  * So the caller has to decrease the reference count after use
304*4882a593Smuzhiyun  * with a call to put_device(&aq->ap_dev.device).
305*4882a593Smuzhiyun  */
306*4882a593Smuzhiyun struct ap_queue *ap_get_qdev(ap_qid_t qid);
307*4882a593Smuzhiyun 
308*4882a593Smuzhiyun /*
309*4882a593Smuzhiyun  * check APQN for owned/reserved by ap bus and default driver(s).
310*4882a593Smuzhiyun  * Checks if this APQN is or will be in use by the ap bus
311*4882a593Smuzhiyun  * and the default set of drivers.
312*4882a593Smuzhiyun  * If yes, returns 1, if not returns 0. On error a negative
313*4882a593Smuzhiyun  * errno value is returned.
314*4882a593Smuzhiyun  */
315*4882a593Smuzhiyun int ap_owned_by_def_drv(int card, int queue);
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun /*
318*4882a593Smuzhiyun  * check 'matrix' of APQNs for owned/reserved by ap bus and
319*4882a593Smuzhiyun  * default driver(s).
320*4882a593Smuzhiyun  * Checks if there is at least one APQN in the given 'matrix'
321*4882a593Smuzhiyun  * marked as owned/reserved by the ap bus and default driver(s).
322*4882a593Smuzhiyun  * If such an APQN is found the return value is 1, otherwise
323*4882a593Smuzhiyun  * 0 is returned. On error a negative errno value is returned.
324*4882a593Smuzhiyun  * The parameter apm is a bitmask which should be declared
325*4882a593Smuzhiyun  * as DECLARE_BITMAP(apm, AP_DEVICES), the aqm parameter is
326*4882a593Smuzhiyun  * similar, should be declared as DECLARE_BITMAP(aqm, AP_DOMAINS).
327*4882a593Smuzhiyun  */
328*4882a593Smuzhiyun int ap_apqn_in_matrix_owned_by_def_drv(unsigned long *apm,
329*4882a593Smuzhiyun 				       unsigned long *aqm);
330*4882a593Smuzhiyun 
331*4882a593Smuzhiyun /*
332*4882a593Smuzhiyun  * ap_parse_mask_str() - helper function to parse a bitmap string
333*4882a593Smuzhiyun  * and clear/set the bits in the bitmap accordingly. The string may be
334*4882a593Smuzhiyun  * given as absolute value, a hex string like 0x1F2E3D4C5B6A" simple
335*4882a593Smuzhiyun  * overwriting the current content of the bitmap. Or as relative string
336*4882a593Smuzhiyun  * like "+1-16,-32,-0x40,+128" where only single bits or ranges of
337*4882a593Smuzhiyun  * bits are cleared or set. Distinction is done based on the very
338*4882a593Smuzhiyun  * first character which may be '+' or '-' for the relative string
339*4882a593Smuzhiyun  * and othewise assume to be an absolute value string. If parsing fails
340*4882a593Smuzhiyun  * a negative errno value is returned. All arguments and bitmaps are
341*4882a593Smuzhiyun  * big endian order.
342*4882a593Smuzhiyun  */
343*4882a593Smuzhiyun int ap_parse_mask_str(const char *str,
344*4882a593Smuzhiyun 		      unsigned long *bitmap, int bits,
345*4882a593Smuzhiyun 		      struct mutex *lock);
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun #endif /* _AP_BUS_H_ */
348