File: classify.c

package info (click to toggle)
irqbalance 0.56-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 344 kB
  • ctags: 277
  • sloc: ansic: 2,132; sh: 105; makefile: 76
file content (135 lines) | stat: -rw-r--r-- 2,627 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include "irqbalance.h"
#include "types.h"


char *classes[] = {
	"other",
	"legacy",
	"storage",
	"timer",
	"ethernet",
	"gbit-ethernet",
	"10gbit-ethernet",
	0
};

int map_class_to_level[7] = 
{ BALANCE_PACKAGE, BALANCE_CACHE, BALANCE_CACHE, BALANCE_NONE, BALANCE_CORE, BALANCE_CORE, BALANCE_CORE };


int class_counts[7];

/*

NOTE NOTE although that this file has a hard-coded list of modules, something missing is not
          a big deal; the types are also set based on PCI class information when available.

*/

/*

   Based on the original irqbalance code which is:

   Copyright (C) 2003 Red Hat, Inc. All rights reserved.
                                                                                                             
   Usage and distribution of this file are subject to the Gnu General Public License Version 2 
   that can be found at http://www.gnu.org/licenses/gpl.txt and the COPYING file as
   distributed together with this file is included herein by reference.  
                                                                                                                      
   Author: Arjan van de Ven   <arjanv@redhat.com>

*/

static char *legacy_modules[] = {
 	"PS/2",
 	"serial",
 	"i8042",
 	"acpi",
	"floppy",
	"parport",
 	"keyboard",
 	"usb-ohci",
	"usb-uhci",
	"uhci_hcd",
	"ohci_hcd",
	"ehci_hcd",
	"EMU10K1",
	0
};

static char *timer_modules[] = {
 	"rtc",
 	"timer",
	0
};

static char *storage_modules[] = {
	"aic7xxx",
	"aic79xx",
	"ide",
	"cciss",
	"cpqarray",
	"qla2",
	"megaraid",
	"fusion",
	"libata",
	"ohci1394",
	"sym53c8xx",
	0
};

static char *ethernet_modules[] = {
	"eth",
	"e100",
	"eepro100",
	"orinoco_cs",
	"wvlan_cs",
	"3c5",	
	"HiSax",
	"skge",
	"sky2",
	0
};


int find_class(struct interrupt *irq, char *moduletext)
{
	int guess = IRQ_OTHER;
	int i;
	
	if (moduletext == NULL)
		return guess;
		
	for (i=0; legacy_modules[i]; i++)
		if (strstr(moduletext, legacy_modules[i]))
			guess = IRQ_LEGACY;

	for (i=0; storage_modules[i]; i++)
		if (strstr(moduletext, storage_modules[i]))
			guess = IRQ_SCSI;

	for (i=0; timer_modules[i]; i++)
		if (strstr(moduletext, timer_modules[i]))
			guess = IRQ_TIMER;
			
	for (i=0; ethernet_modules[i]; i++)
		if (strstr(moduletext, ethernet_modules[i])) {
			guess = IRQ_ETH;
			if (strstr(moduletext, "-rx"))
				guess = IRQ_GETH;
			if (strstr(moduletext, "-tx"))
				guess = IRQ_TGETH;
		}

	if (guess == IRQ_OTHER && irq->number==0)
		guess = IRQ_TIMER;
	
	if (guess >  irq->class)	
		return guess;
        return irq->class;
}