11/*
22 * drivers/s390/cio/blacklist.c
33 * S/390 common I/O routines -- blacklisting of specific devices
4- * $Revision: 1.35 $
4+ * $Revision: 1.39 $
55 *
66 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
77 * IBM Corporation
3535 * These can be single devices or ranges of devices
3636 */
3737
38- /* 65536 bits to indicate if a devno is blacklisted or not */
38+ /* 65536 bits for each set to indicate if a devno is blacklisted or not */
3939#define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \
4040 (8*sizeof(long)))
41- static unsigned long bl_dev [__BL_DEV_WORDS ];
41+ static unsigned long bl_dev [__MAX_SSID + 1 ][ __BL_DEV_WORDS ];
4242typedef enum {add , free } range_action ;
4343
4444/*
4545 * Function: blacklist_range
4646 * (Un-)blacklist the devices from-to
4747 */
4848static inline void
49- blacklist_range (range_action action , unsigned int from , unsigned int to )
49+ blacklist_range (range_action action , unsigned int from , unsigned int to ,
50+ unsigned int ssid )
5051{
5152 if (!to )
5253 to = from ;
5354
54- if (from > to || to > __MAX_SUBCHANNEL ) {
55+ if (from > to || to > __MAX_SUBCHANNEL || ssid > __MAX_SSID ) {
5556 printk (KERN_WARNING "Invalid blacklist range "
56- "0x%04x to 0x%04x, skipping\n" , from , to );
57+ "0.%x.%04x to 0.%x.%04x, skipping\n" ,
58+ ssid , from , ssid , to );
5759 return ;
5860 }
5961 for (; from <= to ; from ++ ) {
6062 if (action == add )
61- set_bit (from , bl_dev );
63+ set_bit (from , bl_dev [ ssid ] );
6264 else
63- clear_bit (from , bl_dev );
65+ clear_bit (from , bl_dev [ ssid ] );
6466 }
6567}
6668
@@ -70,7 +72,7 @@ blacklist_range (range_action action, unsigned int from, unsigned int to)
7072 * Shamelessly grabbed from dasd_devmap.c.
7173 */
7274static inline int
73- blacklist_busid (char * * str , int * id0 , int * id1 , int * devno )
75+ blacklist_busid (char * * str , int * id0 , int * ssid , int * devno )
7476{
7577 int val , old_style ;
7678 char * sav ;
@@ -87,7 +89,7 @@ blacklist_busid(char **str, int *id0, int *id1, int *devno)
8789 goto confused ;
8890 val = simple_strtoul (* str , str , 16 );
8991 if (old_style || (* str )[0 ] != '.' ) {
90- * id0 = * id1 = 0 ;
92+ * id0 = * ssid = 0 ;
9193 if (val < 0 || val > 0xffff )
9294 goto confused ;
9395 * devno = val ;
@@ -106,7 +108,7 @@ blacklist_busid(char **str, int *id0, int *id1, int *devno)
106108 val = simple_strtoul (* str , str , 16 );
107109 if (val < 0 || val > 0xff || (* str )++ [0 ] != '.' )
108110 goto confused ;
109- * id1 = val ;
111+ * ssid = val ;
110112 if (!isxdigit ((* str )[0 ])) /* We require at least one hex digit */
111113 goto confused ;
112114 val = simple_strtoul (* str , str , 16 );
@@ -126,7 +128,7 @@ blacklist_busid(char **str, int *id0, int *id1, int *devno)
126128static inline int
127129blacklist_parse_parameters (char * str , range_action action )
128130{
129- unsigned int from , to , from_id0 , to_id0 , from_id1 , to_id1 ;
131+ unsigned int from , to , from_id0 , to_id0 , from_ssid , to_ssid ;
130132
131133 while (* str != 0 && * str != '\n' ) {
132134 range_action ra = action ;
@@ -143,23 +145,25 @@ blacklist_parse_parameters (char *str, range_action action)
143145 */
144146 if (strncmp (str ,"all," ,4 ) == 0 || strcmp (str ,"all" ) == 0 ||
145147 strncmp (str ,"all\n" ,4 ) == 0 || strncmp (str ,"all " ,4 ) == 0 ) {
146- from = 0 ;
147- to = __MAX_SUBCHANNEL ;
148+ int j ;
149+
148150 str += 3 ;
151+ for (j = 0 ; j <= __MAX_SSID ; j ++ )
152+ blacklist_range (ra , 0 , __MAX_SUBCHANNEL , j );
149153 } else {
150154 int rc ;
151155
152156 rc = blacklist_busid (& str , & from_id0 ,
153- & from_id1 , & from );
157+ & from_ssid , & from );
154158 if (rc )
155159 continue ;
156160 to = from ;
157161 to_id0 = from_id0 ;
158- to_id1 = from_id1 ;
162+ to_ssid = from_ssid ;
159163 if (* str == '-' ) {
160164 str ++ ;
161165 rc = blacklist_busid (& str , & to_id0 ,
162- & to_id1 , & to );
166+ & to_ssid , & to );
163167 if (rc )
164168 continue ;
165169 }
@@ -169,18 +173,19 @@ blacklist_parse_parameters (char *str, range_action action)
169173 strsep (& str , ",\n" ));
170174 continue ;
171175 }
172- if ((from_id0 != to_id0 ) || (from_id1 != to_id1 )) {
176+ if ((from_id0 != to_id0 ) ||
177+ (from_ssid != to_ssid )) {
173178 printk (KERN_WARNING "invalid cio_ignore range "
174179 "%x.%x.%04x-%x.%x.%04x\n" ,
175- from_id0 , from_id1 , from ,
176- to_id0 , to_id1 , to );
180+ from_id0 , from_ssid , from ,
181+ to_id0 , to_ssid , to );
177182 continue ;
178183 }
184+ pr_debug ("blacklist_setup: adding range "
185+ "from %x.%x.%04x to %x.%x.%04x\n" ,
186+ from_id0 , from_ssid , from , to_id0 , to_ssid , to );
187+ blacklist_range (ra , from , to , to_ssid );
179188 }
180- /* FIXME: ignoring id0 and id1 here. */
181- pr_debug ("blacklist_setup: adding range "
182- "from 0.0.%04x to 0.0.%04x\n" , from , to );
183- blacklist_range (ra , from , to );
184189 }
185190 return 1 ;
186191}
@@ -214,9 +219,9 @@ __setup ("cio_ignore=", blacklist_setup);
214219 * Used by validate_subchannel()
215220 */
216221int
217- is_blacklisted (int devno )
222+ is_blacklisted (int ssid , int devno )
218223{
219- return test_bit (devno , bl_dev );
224+ return test_bit (devno , bl_dev [ ssid ] );
220225}
221226
222227#ifdef CONFIG_PROC_FS
@@ -283,6 +288,7 @@ blacklist_parse_proc_parameters (char *buf)
283288/* Iterator struct for all devices. */
284289struct ccwdev_iter {
285290 int devno ;
291+ int ssid ;
286292 int in_range ;
287293};
288294
@@ -291,13 +297,14 @@ cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset)
291297{
292298 struct ccwdev_iter * iter ;
293299
294- if (* offset > __MAX_SUBCHANNEL )
300+ if (* offset >= ( __MAX_SUBCHANNEL + 1 ) * ( __MAX_SSID + 1 ) )
295301 return NULL ;
296302 iter = kmalloc (sizeof (struct ccwdev_iter ), GFP_KERNEL );
297303 if (!iter )
298304 return ERR_PTR (- ENOMEM );
299305 memset (iter , 0 , sizeof (struct ccwdev_iter ));
300- iter -> devno = * offset ;
306+ iter -> ssid = * offset / (__MAX_SUBCHANNEL + 1 );
307+ iter -> devno = * offset % (__MAX_SUBCHANNEL + 1 );
301308 return iter ;
302309}
303310
@@ -313,10 +320,16 @@ cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset)
313320{
314321 struct ccwdev_iter * iter ;
315322
316- if (* offset > __MAX_SUBCHANNEL )
323+ if (* offset >= ( __MAX_SUBCHANNEL + 1 ) * ( __MAX_SSID + 1 ) )
317324 return NULL ;
318325 iter = (struct ccwdev_iter * )it ;
319- iter -> devno ++ ;
326+ if (iter -> devno == __MAX_SUBCHANNEL ) {
327+ iter -> devno = 0 ;
328+ iter -> ssid ++ ;
329+ if (iter -> ssid > __MAX_SSID )
330+ return NULL ;
331+ } else
332+ iter -> devno ++ ;
320333 (* offset )++ ;
321334 return iter ;
322335}
@@ -327,23 +340,24 @@ cio_ignore_proc_seq_show(struct seq_file *s, void *it)
327340 struct ccwdev_iter * iter ;
328341
329342 iter = (struct ccwdev_iter * )it ;
330- if (!is_blacklisted (iter -> devno ))
343+ if (!is_blacklisted (iter -> ssid , iter -> devno ))
331344 /* Not blacklisted, nothing to output. */
332345 return 0 ;
333346 if (!iter -> in_range ) {
334347 /* First device in range. */
335348 if ((iter -> devno == __MAX_SUBCHANNEL ) ||
336- !is_blacklisted (iter -> devno + 1 ))
349+ !is_blacklisted (iter -> ssid , iter -> devno + 1 ))
337350 /* Singular device. */
338- return seq_printf (s , "0.0.%04x\n" , iter -> devno );
351+ return seq_printf (s , "0.%x.%04x\n" ,
352+ iter -> ssid , iter -> devno );
339353 iter -> in_range = 1 ;
340- return seq_printf (s , "0.0 .%04x-" , iter -> devno );
354+ return seq_printf (s , "0.%x .%04x-" , iter -> ssid , iter -> devno );
341355 }
342356 if ((iter -> devno == __MAX_SUBCHANNEL ) ||
343- !is_blacklisted (iter -> devno + 1 )) {
357+ !is_blacklisted (iter -> ssid , iter -> devno + 1 )) {
344358 /* Last device in range. */
345359 iter -> in_range = 0 ;
346- return seq_printf (s , "0.0 .%04x\n" , iter -> devno );
360+ return seq_printf (s , "0.%x .%04x\n" , iter -> ssid , iter -> devno );
347361 }
348362 return 0 ;
349363}
0 commit comments