Zephyr API Documentation 4.4.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;
46 uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_PACKET_SIZE(MCTP_USB_MAX_PACKET_LENGTH))]
47 PKTBUF_STORAGE_ALIGN;
49};
50
65
67int mctp_usb_start(struct mctp_binding *binding);
68int mctp_usb_tx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
70
78#define MCTP_USB_DEFINE(_name, _subclass, _protocol) \
79 struct mctp_binding_usb _name = { \
80 .binding = { \
81 .name = STRINGIFY(_name), \
82 .version = 1, \
83 .pkt_size = MCTP_PACKET_SIZE(MCTP_USB_MAX_PACKET_LENGTH), \
84 .pkt_header = 0, \
85 .pkt_trailer = 0, \
86 .tx_storage = _name.tx_storage, \
87 .start = mctp_usb_start, \
88 .tx = mctp_usb_tx \
89 }, \
90 .usb_class_data = NULL, \
91 .rx_pkt = NULL, \
92 .rx_data_idx = 0, \
93 .rx_state = STATE_WAIT_HDR_DMTF0 \
94 }; \
95 \
96 const STRUCT_SECTION_ITERABLE(mctp_usb_class_inst, mctp_usb_class_inst_##_name) = { \
97 .subclass = _subclass, \
98 .mctp_protocol = _protocol, \
99 .mctp_binding = &_name, \
100 };
101
102#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:3667
An MCTP binding for Zephyr's USB device stack.
Definition mctp_usb.h:31
MCTP USB class instance configuration.
Definition mctp_usb.h:57
uint8_t subclass
MCTP subclass used in the USB interface descriptor.
Definition mctp_usb.h:59
uint8_t mctp_protocol
MCTP protocol version used in the USB interface descriptor.
Definition mctp_usb.h:61
struct mctp_binding_usb * mctp_binding
Pointer to the associated MCTP USB bus binding.
Definition mctp_usb.h:63
USB device support class data.
Definition usbd.h:382