Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mctp_usb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Intel Corporation
3 * Copyright 2025 NXP
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 */
8
9#ifndef ZEPHYR_MCTP_USB_H_
10#define ZEPHYR_MCTP_USB_H_
11
13#include <libmctp.h>
14
15/* MCTP class subclass options */
16#define USBD_MCTP_SUBCLASS_MANAGEMENT_CONTROLLER 0
17#define USBD_MCTP_SUBCLASS_MANAGED_DEVICE_ENDPOINT 0
18#define USBD_MCTP_SUBCLASS_HOST_INTERFACE_ENDPOINT 1
19
20/* MCTP class protocol options */
21#define USBD_MCTP_PROTOCOL_1_X 1
22#define USBD_MCTP_PROTOCOL_2_X 2
23
24/* Binding-specific defines, internal use */
25#define MCTP_USB_HEADER_SIZE 4
26#define MCTP_USB_MAX_PACKET_LENGTH 255
27
33 struct mctp_binding binding;
34 struct usbd_class_data *usb_class_data;
36 struct k_sem tx_lock;
37 struct mctp_pktbuf *rx_pkt;
38 uint8_t rx_data_idx;
39 enum {
40 STATE_WAIT_HDR_DMTF0,
41 STATE_WAIT_HDR_DMTF1,
42 STATE_WAIT_HDR_RSVD0,
43 STATE_WAIT_HDR_LEN,
44 STATE_DATA
45 } rx_state;
47};
48
54
56int mctp_usb_start(struct mctp_binding *binding);
57int mctp_usb_tx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
59
67#define MCTP_USB_DEFINE(_name, _subclass, _protocol) \
68 struct mctp_binding_usb _name = { \
69 .binding = { \
70 .name = STRINGIFY(_name), \
71 .version = 1, \
72 .pkt_size = MCTP_PACKET_SIZE(MCTP_USB_MAX_PACKET_LENGTH), \
73 .pkt_header = 0, \
74 .pkt_trailer = 0, \
75 .start = mctp_usb_start, \
76 .tx = mctp_usb_tx \
77 }, \
78 .usb_class_data = NULL, \
79 .rx_pkt = NULL, \
80 .rx_data_idx = 0, \
81 .rx_state = STATE_WAIT_HDR_DMTF0 \
82 }; \
83 \
84 const STRUCT_SECTION_ITERABLE(mctp_usb_class_inst, mctp_usb_class_inst_##_name) = { \
85 .sublcass = _subclass, \
86 .mctp_protocol = _protocol, \
87 .mctp_binding = &_name, \
88 };
89
90#endif /* ZEPHYR_MCTP_USB_H_ */
#define MCTP_USB_MAX_PACKET_LENGTH
Definition mctp_usb.h:26
#define MCTP_USB_HEADER_SIZE
Definition mctp_usb.h:25
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Semaphore structure.
Definition kernel.h:3418
An MCTP binding for Zephyr's USB device stack.
Definition mctp_usb.h:31
Definition mctp_usb.h:49
uint8_t sublcass
Definition mctp_usb.h:50
uint8_t mctp_protocol
Definition mctp_usb.h:51
struct mctp_binding_usb * mctp_binding
Definition mctp_usb.h:52
USB device support class data.
Definition usbd.h:378