xref: /illumos-gate/usr/src/man/man9f/mac_devt_to_instance.9f (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2023 Oxide Computer Company
13.\"
14.Dd January 30, 2023
15.Dt MAC_DEVT_TO_INSTANCE 9F
16.Os
17.Sh NAME
18.Nm mac_devt_to_instance
19.Nd return the instance number for the given device number
20.Sh SYNOPSIS
21.In sys/mac_provider.h
22.Ft int
23.Fo mac_devt_to_instance
24.Fa "dev_t devt"
25.Fc
26.Sh INTERFACE LEVEL
27illumos DDI specific
28.Sh PARAMETERS
29.Bl -tag -width Fa
30.It Fa "devt"
31Device number.
32.El
33.Sh DESCRIPTION
34The
35.Fn mac_devt_to_instance
36function returns the device instance number associated with the given device
37number managed by the
38.Xr mac 9E
39framework.
40.Pp
41Generally the MAC framework is responsible for managing device instance
42mapping and provides a default
43.Xr getinfo 9E
44implementation to that effect.
45.Pp
46However, if a driver wants to expose additional device nodes or relies on some
47special mapping of device instance to MAC instance then it must provide its own
48.Xr getinfo 9E
49entry point.
50In that case, the driver can call the
51.Fn mac_devt_to_instance
52function to obtain the MAC specific instance number and translate it as
53appropriate to a devinfo instance.
54.Sh CONTEXT
55The
56.Fn mac_devt_to_instance
57function should be called from a
58.Sy kernel
59context and is generally used during the execution of a driver's
60.Xr getinfo 9E
61entry point.
62.Sh RETURN VALUES
63Upon successful completion, the
64.Fn mac_devt_to_instance
65function returns the instance number associated with the minor.
66Otherwise
67.Sy -1
68is returned to indicate failure.
69.Sh SEE ALSO
70.Xr getinfo 9E ,
71.Xr mac 9E ,
72.Xr ddi_get_instance 9F ,
73.Xr mac_getinfo 9F ,
74.Xr mac_private_minor 9F
75