Zephyr Project API  3.3.0
A Scalable Open Source RTOS
smp.h
Go to the documentation of this file.
1/*
2 * Copyright Runtime.io 2018. All rights reserved.
3 * Copyright (c) 2022 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef ZEPHYR_INCLUDE_MGMT_SMP_H_
9#define ZEPHYR_INCLUDE_MGMT_SMP_H_
10
11#include <zephyr/kernel.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
24struct smp_transport;
26struct net_buf;
27
37typedef int (*smp_transport_out_fn)(struct net_buf *nb);
38/* use smp_transport_out_fn instead */
39typedef int zephyr_smp_transport_out_fn(struct net_buf *nb);
40
54typedef uint16_t (*smp_transport_get_mtu_fn)(const struct net_buf *nb);
55/* use smp_transport_get_mtu_fn instead */
57
71typedef int (*smp_transport_ud_copy_fn)(struct net_buf *dst,
72 const struct net_buf *src);
73/* use smp_transport_ud_copy_fn instead */
75 const struct net_buf *src);
76
86typedef void (*smp_transport_ud_free_fn)(void *ud);
87/* use smp_transport_ud_free_fn instead */
88typedef void zephyr_smp_transport_ud_free_fn(void *ud);
89
101typedef bool (*smp_transport_query_valid_check_fn)(struct net_buf *nb, void *arg);
102
107 /* Must be the first member. */
108 struct k_work work;
109
110 /* FIFO containing incoming requests to be processed. */
111 struct k_fifo fifo;
112
118
119#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
120 /* Packet reassembly internal data, API access only */
121 struct {
122 struct net_buf *current; /* net_buf used for reassembly */
123 uint16_t expected; /* expected bytes to come */
124 } __reassembly;
125#endif
126};
127
128/* Deprecated, use smp_transport instead */
130 /* Must be the first member. */
132
133 /* FIFO containing incoming requests to be processed. */
135
140
141#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
142 /* Packet reassembly internal data, API access only */
143 struct {
144 struct net_buf *current; /* net_buf used for reassembly */
145 uint16_t expected; /* expected bytes to come */
146 } __reassembly;
147#endif
148};
149
161 smp_transport_out_fn output_func,
162 smp_transport_get_mtu_fn get_mtu_func,
163 smp_transport_ud_copy_fn ud_copy_func,
164 smp_transport_ud_free_fn ud_free_func,
165 smp_transport_query_valid_check_fn query_valid_check_func);
166
167__deprecated static inline
169 zephyr_smp_transport_out_fn *output_func,
173{
174 smp_transport_init((struct smp_transport *)smpt,
175 (smp_transport_out_fn)output_func,
176 (smp_transport_get_mtu_fn)get_mtu_func,
177 (smp_transport_ud_copy_fn)ud_copy_func,
178 (smp_transport_ud_free_fn)ud_free_func, NULL);
179}
180
190void smp_rx_remove_invalid(struct smp_transport *zst, void *arg);
191
197void smp_rx_clear(struct smp_transport *zst);
198
203#ifdef __cplusplus
204}
205#endif
206
207#endif
int zephyr_smp_transport_ud_copy_fn(struct net_buf *dst, const struct net_buf *src)
Definition: smp.h:74
int(* smp_transport_ud_copy_fn)(struct net_buf *dst, const struct net_buf *src)
SMP copy user_data callback.
Definition: smp.h:71
void smp_rx_clear(struct smp_transport *zst)
Used to clear pending queued requests for an SMP transport.
void zephyr_smp_transport_ud_free_fn(void *ud)
Definition: smp.h:88
static void zephyr_smp_transport_init(struct zephyr_smp_transport *smpt, zephyr_smp_transport_out_fn *output_func, zephyr_smp_transport_get_mtu_fn *get_mtu_func, zephyr_smp_transport_ud_copy_fn *ud_copy_func, zephyr_smp_transport_ud_free_fn *ud_free_func)
Definition: smp.h:168
void(* smp_transport_ud_free_fn)(void *ud)
SMP free user_data callback.
Definition: smp.h:86
void smp_rx_remove_invalid(struct smp_transport *zst, void *arg)
Used to remove queued requests for an SMP transport that are no longer valid. A smp_transport_query_v...
int(* smp_transport_out_fn)(struct net_buf *nb)
SMP transmit callback for transport.
Definition: smp.h:37
uint16_t zephyr_smp_transport_get_mtu_fn(const struct net_buf *nb)
Definition: smp.h:56
bool(* smp_transport_query_valid_check_fn)(struct net_buf *nb, void *arg)
Function for checking if queued data is still valid.
Definition: smp.h:101
int zephyr_smp_transport_out_fn(struct net_buf *nb)
Definition: smp.h:39
uint16_t(* smp_transport_get_mtu_fn)(const struct net_buf *nb)
SMP MTU query callback for transport.
Definition: smp.h:54
void smp_transport_init(struct smp_transport *smpt, smp_transport_out_fn output_func, smp_transport_get_mtu_fn get_mtu_func, smp_transport_ud_copy_fn ud_copy_func, smp_transport_ud_free_fn ud_free_func, smp_transport_query_valid_check_fn query_valid_check_func)
Initializes a Zephyr SMP transport object.
Public kernel APIs.
#define bool
Definition: stdbool.h:13
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Definition: kernel.h:2252
A structure used to submit work.
Definition: kernel.h:3707
Network buffer representation.
Definition: buf.h:905
SMP transport object for sending SMP responses.
Definition: smp.h:106
struct k_work work
Definition: smp.h:108
smp_transport_out_fn output
Definition: smp.h:113
smp_transport_query_valid_check_fn query_valid_check
Definition: smp.h:117
smp_transport_ud_free_fn ud_free
Definition: smp.h:116
smp_transport_get_mtu_fn get_mtu
Definition: smp.h:114
struct k_fifo fifo
Definition: smp.h:111
smp_transport_ud_copy_fn ud_copy
Definition: smp.h:115
Definition: smp.h:129
struct k_work zst_work
Definition: smp.h:131
smp_transport_get_mtu_fn zst_get_mtu
Definition: smp.h:137
struct k_fifo zst_fifo
Definition: smp.h:134
smp_transport_ud_copy_fn zst_ud_copy
Definition: smp.h:138
smp_transport_out_fn zst_output
Definition: smp.h:136
smp_transport_ud_free_fn zst_ud_free
Definition: smp.h:139
static ZTEST_BMEM struct thread_data expected