xref: /openbsd-src/share/man/man9/intrmap_create.9 (revision bddde17d7808bef43ccb0e22335f8f162f7a26a0)
1*bddde17dSdenis.\" $OpenBSD: intrmap_create.9,v 1.4 2022/07/31 12:55:31 denis Exp $
2795d573fSdlg.\"
3795d573fSdlg.\" Copyright (c) 2020 David Gwynne <dlg@openbsd.org>
4795d573fSdlg.\"
5795d573fSdlg.\" Permission to use, copy, modify, and distribute this software for any
6795d573fSdlg.\" purpose with or without fee is hereby granted, provided that the above
7795d573fSdlg.\" copyright notice and this permission notice appear in all copies.
8795d573fSdlg.\"
9795d573fSdlg.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10795d573fSdlg.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11795d573fSdlg.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12795d573fSdlg.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13795d573fSdlg.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14795d573fSdlg.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15795d573fSdlg.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16795d573fSdlg.\"
17*bddde17dSdenis.Dd $Mdocdate: July 31 2022 $
18795d573fSdlg.Dt INTRMAP_CREATE 9
19795d573fSdlg.Os
20795d573fSdlg.Sh NAME
21795d573fSdlg.Nm intrmap_create ,
22795d573fSdlg.Nm intrmap_destroy ,
23795d573fSdlg.Nm intrmap_count ,
24795d573fSdlg.Nm intrmap_cpu
25795d573fSdlg.Nd interrupt to CPU mapping API
26795d573fSdlg.Sh SYNOPSIS
27*bddde17dSdenis.In sys/intrmap.h
28795d573fSdlg.Ft struct intrmap *
29795d573fSdlg.Fo intrmap_create
30795d573fSdlg.Fa "const struct device *dv"
31795d573fSdlg.Fa "unsigned int nintr"
32795d573fSdlg.Fa "unsigned int maxintr"
33795d573fSdlg.Fa "unsigned int flags"
34795d573fSdlg.Fc
35795d573fSdlg.Ft void
36795d573fSdlg.Fn intrmap_destroy "struct intrmap *im"
37795d573fSdlg.Ft unsigned int
38795d573fSdlg.Fn intrmap_count "struct intrmap *im"
39d9f5f731Sdlg.Ft struct cpu_info *
40795d573fSdlg.Fn intrmap_cpu "struct intrmap *im" "unsigned int index"
41795d573fSdlg.Sh DESCRIPTION
42795d573fSdlgThe interrupt to CPU mapping API supports the use of multiple CPUs
43795d573fSdlgby hardware drivers.
44795d573fSdlgDrivers that can use multiple interrupts use the API to request a
45795d573fSdlgset of CPUs that they can establish those interrupts on.
46795d573fSdlgThe API limits the requested number of interrupts to what is available
47795d573fSdlgon the system, and attempts to distribute the requested interrupts
48795d573fSdlgover those CPUs.
49795d573fSdlgOn some platforms the API will filter the set of available CPUs.
50795d573fSdlg.\" to avoid hyperthreads, basically.
51795d573fSdlg.Pp
52795d573fSdlg.Fn intrmap_create
53795d573fSdlgallocates an interrupt map data structure for use by the driver
54795d573fSdlgidentified by
55795d573fSdlg.Fa dv .
56795d573fSdlgThe number of interrupts the hardware supports is specified via the
57795d573fSdlg.Fa nintr
58795d573fSdlgargument.
59795d573fSdlgThe driver supplies the maximum number of interrupts it can support
60795d573fSdlgvia
61795d573fSdlg.Fa maxintr ,
62795d573fSdlgwhich, along with the number of available CPUs at the time the
63795d573fSdlgfunction is called, is used as a constraint on the number of requested
64795d573fSdlginterrupts.
65795d573fSdlg.Fa nintr
66795d573fSdlgmay be zero to use the driver limit as the number of requested
67795d573fSdlginterrupts.
68795d573fSdlgThe
69795d573fSdlg.Fa flags
70795d573fSdlgargument may have the following defines OR'ed together:
71795d573fSdlg.Bl -tag -width xxx -offset indent
72795d573fSdlg.It Dv INTRMAP_POWEROF2
73795d573fSdlgThe hardware only supports a power of 2 number of interrupts, so
74795d573fSdlgconstrain the number of supplied interrupts after the system and
75795d573fSdlgdriver limits are applied.
76795d573fSdlg.El
77795d573fSdlg.Pp
78795d573fSdlg.Fn intrmap_destroy
79795d573fSdlgfrees the memory associated with the interrupt map data structure
80795d573fSdlgpassed via
81795d573fSdlg.Fa im .
82795d573fSdlg.Pp
83795d573fSdlg.Fn intrmap_count
84795d573fSdlgreturns the number of interrupts that the driver can establish
85795d573fSdlgaccording to the
86795d573fSdlg.Fa im
87795d573fSdlginterrupt map.
88795d573fSdlg.Pp
89795d573fSdlg.Fn intrmap_cpu
90795d573fSdlgreturns which CPU the interrupt specified in
91795d573fSdlg.Fa index
92795d573fSdlgshould be established on according to the
93795d573fSdlg.Fa im
94795d573fSdlginterrupt map.
95795d573fSdlgInterrupts are identified as a number from 0 to the value returned by
96795d573fSdlg.Fn intrmap_count .
97795d573fSdlg.Sh CONTEXT
98795d573fSdlg.Fn intrmap_create ,
99795d573fSdlg.Fn intrmap_destroy ,
100795d573fSdlg.Fn intrmap_count ,
101795d573fSdlgand
102795d573fSdlg.Fn intrmap_cpu
103795d573fSdlgcan be called during autoconf, or from process context.
104795d573fSdlg.Sh RETURN VALUES
105795d573fSdlg.Fn intrmap_create
106d2815251Sjmcreturns a pointer to an interrupt mapping structure on success, or
107795d573fSdlg.Dv NULL
108795d573fSdlgon failure.
109795d573fSdlg.Pp
110795d573fSdlg.Fn intrmap_count
111795d573fSdlgreturns the number of interrupts that were allocated for the driver
112795d573fSdlgto use.
113795d573fSdlg.Pp
114795d573fSdlg.Fn intrmap_cpu
115d2815251Sjmcreturns a pointer to the cpu_info structure for the CPU that the
116d9f5f731Sdlginterrupt should be established on.
117795d573fSdlg.\" .Sh SEE ALSO
118795d573fSdlg.\" .Xr pci_intr_establish_cpuid 9
119795d573fSdlg.Sh HISTORY
120795d573fSdlgThe interrupt mapping API is based on the if_ringmap API in
121795d573fSdlg.Dx .
122795d573fSdlgIt was ported to
123795d573fSdlg.Ox 6.8
124795d573fSdlgby
125795d573fSdlg.An David Gwynne Aq Mt dlg@openbsd.org .
126