Zephyr Project API 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
14
15#ifndef ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_USB_H_
16#define ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_USB_H_
17
19#include <libmctp.h>
20
28#define USBD_MCTP_SUBCLASS_MANAGEMENT_CONTROLLER 0
30#define USBD_MCTP_SUBCLASS_MANAGED_DEVICE_ENDPOINT 0
32#define USBD_MCTP_SUBCLASS_HOST_INTERFACE_ENDPOINT 1
34
42#define USBD_MCTP_PROTOCOL_1_X 1
44#define USBD_MCTP_PROTOCOL_2_X 2
46
48/* Binding-specific defines, internal use */
49#define MCTP_USB_HEADER_SIZE 4
50#define MCTP_USB_MAX_PACKET_LENGTH 255
52
58 struct mctp_binding binding;
59 struct usbd_class_data *usb_class_data;
60 uint8_t tx_buf[MCTP_USB_HEADER_SIZE + MCTP_USB_MAX_PACKET_LENGTH];
61 struct k_sem tx_lock;
62 struct mctp_pktbuf *rx_pkt;
63 uint8_t rx_data_idx;
64 enum {
65 STATE_WAIT_HDR_DMTF0,
66 STATE_WAIT_HDR_DMTF1,
67 STATE_WAIT_HDR_RSVD0,
68 STATE_WAIT_HDR_LEN,
69 STATE_DATA
70 } rx_state;
71 uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_PACKET_SIZE(MCTP_USB_MAX_PACKET_LENGTH))]
72 PKTBUF_STORAGE_ALIGN;
74};
75
90
92int mctp_usb_start(struct mctp_binding *binding);
93int mctp_usb_tx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
95
103#define MCTP_USB_DEFINE(_name, _subclass, _protocol) \
104 struct mctp_binding_usb _name = { \
105 .binding = { \
106 .name = STRINGIFY(_name), \
107 .version = 1, \
108 .pkt_size = MCTP_PACKET_SIZE(MCTP_USB_MAX_PACKET_LENGTH), \
109 .pkt_header = 0, \
110 .pkt_trailer = 0, \
111 .tx_storage = _name.tx_storage, \
112 .start = mctp_usb_start, \
113 .tx = mctp_usb_tx \
114 }, \
115 .usb_class_data = NULL, \
116 .rx_pkt = NULL, \
117 .rx_data_idx = 0, \
118 .rx_state = STATE_WAIT_HDR_DMTF0 \
119 }; \
120 \
121 const STRUCT_SECTION_ITERABLE(mctp_usb_class_inst, mctp_usb_class_inst_##_name) = { \
122 .subclass = _subclass, \
123 .mctp_protocol = _protocol, \
124 .mctp_binding = &_name, \
125 };
126
127#endif /* ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_USB_H_ */
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Semaphore structure.
Definition kernel.h:3798
INTERNAL_HIDDEN.
Definition mctp_usb.h:56
MCTP USB class instance configuration.
Definition mctp_usb.h:82
uint8_t subclass
MCTP subclass used in the USB interface descriptor.
Definition mctp_usb.h:84
uint8_t mctp_protocol
MCTP protocol version used in the USB interface descriptor.
Definition mctp_usb.h:86
struct mctp_binding_usb * mctp_binding
Pointer to the associated MCTP USB bus binding.
Definition mctp_usb.h:88
USB device support class data.
Definition usbd.h:396
Iterable sections helpers.