162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciIntroduction
462306a36Sopenharmony_ci============
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciThe Intel Management Engine (Intel ME) is an isolated and protected computing
762306a36Sopenharmony_ciresource (Co-processor) residing inside certain Intel chipsets. The Intel ME
862306a36Sopenharmony_ciprovides support for computer/IT management and security features.
962306a36Sopenharmony_ciThe actual feature set depends on the Intel chipset SKU.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciThe Intel Management Engine Interface (Intel MEI, previously known as HECI)
1262306a36Sopenharmony_ciis the interface between the Host and Intel ME. This interface is exposed
1362306a36Sopenharmony_cito the host as a PCI device, actually multiple PCI devices might be exposed.
1462306a36Sopenharmony_ciThe Intel MEI Driver is in charge of the communication channel between
1562306a36Sopenharmony_cia host application and the Intel ME features.
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciEach Intel ME feature, or Intel ME Client is addressed by a unique GUID and
1862306a36Sopenharmony_cieach client has its own protocol. The protocol is message-based with a
1962306a36Sopenharmony_ciheader and payload up to maximal number of bytes advertised by the client,
2062306a36Sopenharmony_ciupon connection.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciIntel MEI Driver
2362306a36Sopenharmony_ci================
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciThe driver exposes a character device with device nodes /dev/meiX.
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciAn application maintains communication with an Intel ME feature while
2862306a36Sopenharmony_ci/dev/meiX is open. The binding to a specific feature is performed by calling
2962306a36Sopenharmony_ci:c:macro:`MEI_CONNECT_CLIENT_IOCTL`, which passes the desired GUID.
3062306a36Sopenharmony_ciThe number of instances of an Intel ME feature that can be opened
3162306a36Sopenharmony_ciat the same time depends on the Intel ME feature, but most of the
3262306a36Sopenharmony_cifeatures allow only a single instance.
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciThe driver is transparent to data that are passed between firmware feature
3562306a36Sopenharmony_ciand host application.
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciBecause some of the Intel ME features can change the system
3862306a36Sopenharmony_ciconfiguration, the driver by default allows only a privileged
3962306a36Sopenharmony_ciuser to access it.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ciThe session is terminated calling :c:expr:`close(fd)`.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciA code snippet for an application communicating with Intel AMTHI client:
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciIn order to support virtualization or sandboxing a trusted supervisor
4662306a36Sopenharmony_cican use :c:macro:`MEI_CONNECT_CLIENT_IOCTL_VTAG` to create
4762306a36Sopenharmony_civirtual channels with an Intel ME feature. Not all features support
4862306a36Sopenharmony_civirtual channels such client with answer EOPNOTSUPP.
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci.. code-block:: C
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci	struct mei_connect_client_data data;
5362306a36Sopenharmony_ci	fd = open(MEI_DEVICE);
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci	data.d.in_client_uuid = AMTHI_GUID;
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci	ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &data);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci	printf("Ver=%d, MaxLen=%ld\n",
6062306a36Sopenharmony_ci	       data.d.in_client_uuid.protocol_version,
6162306a36Sopenharmony_ci	       data.d.in_client_uuid.max_msg_length);
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci	[...]
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci	write(fd, amthi_req_data, amthi_req_data_len);
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	[...]
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci	read(fd, &amthi_res_data, amthi_res_data_len);
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci	[...]
7262306a36Sopenharmony_ci	close(fd);
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciUser space API
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ciIOCTLs:
7862306a36Sopenharmony_ci=======
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciThe Intel MEI Driver supports the following IOCTL commands:
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciIOCTL_MEI_CONNECT_CLIENT
8362306a36Sopenharmony_ci-------------------------
8462306a36Sopenharmony_ciConnect to firmware Feature/Client.
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci.. code-block:: none
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci	Usage:
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci        struct mei_connect_client_data client_data;
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci        ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &client_data);
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	Inputs:
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci        struct mei_connect_client_data - contain the following
9762306a36Sopenharmony_ci	Input field:
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci		in_client_uuid -	GUID of the FW Feature that needs
10062306a36Sopenharmony_ci					to connect to.
10162306a36Sopenharmony_ci         Outputs:
10262306a36Sopenharmony_ci		out_client_properties - Client Properties: MTU and Protocol Version.
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci         Error returns:
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci                ENOTTY  No such client (i.e. wrong GUID) or connection is not allowed.
10762306a36Sopenharmony_ci		EINVAL	Wrong IOCTL Number
10862306a36Sopenharmony_ci		ENODEV	Device or Connection is not initialized or ready.
10962306a36Sopenharmony_ci		ENOMEM	Unable to allocate memory to client internal data.
11062306a36Sopenharmony_ci		EFAULT	Fatal Error (e.g. Unable to access user input data)
11162306a36Sopenharmony_ci		EBUSY	Connection Already Open
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci:Note:
11462306a36Sopenharmony_ci        max_msg_length (MTU) in client properties describes the maximum
11562306a36Sopenharmony_ci        data that can be sent or received. (e.g. if MTU=2K, can send
11662306a36Sopenharmony_ci        requests up to bytes 2k and received responses up to 2k bytes).
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ciIOCTL_MEI_CONNECT_CLIENT_VTAG:
11962306a36Sopenharmony_ci------------------------------
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci.. code-block:: none
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci        Usage:
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci        struct mei_connect_client_data_vtag client_data_vtag;
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci        ioctl(fd, IOCTL_MEI_CONNECT_CLIENT_VTAG, &client_data_vtag);
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci        Inputs:
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci        struct mei_connect_client_data_vtag - contain the following
13262306a36Sopenharmony_ci        Input field:
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci                in_client_uuid -  GUID of the FW Feature that needs
13562306a36Sopenharmony_ci                                  to connect to.
13662306a36Sopenharmony_ci                vtag - virtual tag [1, 255]
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci         Outputs:
13962306a36Sopenharmony_ci                out_client_properties - Client Properties: MTU and Protocol Version.
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci         Error returns:
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci                ENOTTY No such client (i.e. wrong GUID) or connection is not allowed.
14462306a36Sopenharmony_ci                EINVAL Wrong IOCTL Number or tag == 0
14562306a36Sopenharmony_ci                ENODEV Device or Connection is not initialized or ready.
14662306a36Sopenharmony_ci                ENOMEM Unable to allocate memory to client internal data.
14762306a36Sopenharmony_ci                EFAULT Fatal Error (e.g. Unable to access user input data)
14862306a36Sopenharmony_ci                EBUSY  Connection Already Open
14962306a36Sopenharmony_ci                EOPNOTSUPP Vtag is not supported
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ciIOCTL_MEI_NOTIFY_SET
15262306a36Sopenharmony_ci---------------------
15362306a36Sopenharmony_ciEnable or disable event notifications.
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci.. code-block:: none
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci	Usage:
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci		uint32_t enable;
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci		ioctl(fd, IOCTL_MEI_NOTIFY_SET, &enable);
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci		uint32_t enable = 1;
16662306a36Sopenharmony_ci		or
16762306a36Sopenharmony_ci		uint32_t enable[disable] = 0;
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci	Error returns:
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci		EINVAL	Wrong IOCTL Number
17362306a36Sopenharmony_ci		ENODEV	Device  is not initialized or the client not connected
17462306a36Sopenharmony_ci		ENOMEM	Unable to allocate memory to client internal data.
17562306a36Sopenharmony_ci		EFAULT	Fatal Error (e.g. Unable to access user input data)
17662306a36Sopenharmony_ci		EOPNOTSUPP if the device doesn't support the feature
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci:Note:
17962306a36Sopenharmony_ci	The client must be connected in order to enable notification events
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ciIOCTL_MEI_NOTIFY_GET
18362306a36Sopenharmony_ci--------------------
18462306a36Sopenharmony_ciRetrieve event
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci.. code-block:: none
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci	Usage:
18962306a36Sopenharmony_ci		uint32_t event;
19062306a36Sopenharmony_ci		ioctl(fd, IOCTL_MEI_NOTIFY_GET, &event);
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci	Outputs:
19362306a36Sopenharmony_ci		1 - if an event is pending
19462306a36Sopenharmony_ci		0 - if there is no even pending
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci	Error returns:
19762306a36Sopenharmony_ci		EINVAL	Wrong IOCTL Number
19862306a36Sopenharmony_ci		ENODEV	Device is not initialized or the client not connected
19962306a36Sopenharmony_ci		ENOMEM	Unable to allocate memory to client internal data.
20062306a36Sopenharmony_ci		EFAULT	Fatal Error (e.g. Unable to access user input data)
20162306a36Sopenharmony_ci		EOPNOTSUPP if the device doesn't support the feature
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci:Note:
20462306a36Sopenharmony_ci	The client must be connected and event notification has to be enabled
20562306a36Sopenharmony_ci	in order to receive an event
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ciSupported Chipsets
21062306a36Sopenharmony_ci==================
21162306a36Sopenharmony_ci82X38/X48 Express and newer
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_cilinux-mei@linux.intel.com
214