Zephyr API Documentation 4.5.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
smp.h
Go to the documentation of this file.
1/*
2 * Copyright Runtime.io 2018. All rights reserved.
3 * Copyright (c) 2022-2023 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_SMP_H_
9#define ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_SMP_H_
10
11#include <zephyr/kernel.h>
12#include <zcbor_common.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
24
25struct smp_transport;
26struct zephyr_smp_transport;
27struct net_buf;
30
46typedef int (*smp_transport_out_fn)(struct net_buf *nb);
47
64typedef uint16_t (*smp_transport_get_mtu_fn)(const struct net_buf *nb) __deprecated;
65
79typedef int (*smp_transport_ud_copy_fn)(struct net_buf *dst,
80 const struct net_buf *src);
81
91typedef void (*smp_transport_ud_free_fn)(void *ud);
92
104typedef bool (*smp_transport_query_valid_check_fn)(struct net_buf *nb, void *arg);
105
114typedef void (*smp_transport_ud_req_init_fn)(struct net_buf *nb, void *priv);
115
134 bool direction, uint32_t mode, bool same_transport,
135 zcbor_state_t *input_data,
136 zcbor_state_t *output_data);
137
149 bool direction);
150
164typedef int (*smp_transport_bridge_out_fn)(const struct smp_transport_bridge *bridge,
165 struct net_buf *nb, bool direction);
166
176 void *user_data);
177
188typedef bool (*smp_transport_bridge_modes_fn)(zcbor_state_t *output_data, int *rc);
189
201typedef bool (*smp_transport_bridge_config_details_fn)(uint32_t mode, zcbor_state_t *output_data,
202 int *rc);
203
250
255 /* Must be the first member. */
256 struct k_work work;
257
258 /* FIFO containing incoming requests to be processed. */
259 struct k_fifo fifo;
260
261 /* Function pointers */
263
264#ifdef CONFIG_MCUMGR_TRANSPORT_REASSEMBLY
265 /* Packet reassembly internal data, API access only */
266 struct {
267 struct net_buf *current; /* net_buf used for reassembly */
268 uint16_t expected; /* expected bytes to come */
269 } __reassembly;
270#endif
271};
272
292
319
329
330#if defined(CONFIG_MCUMGR_GRP_TRANSPORT_INFO_FUNCTIONS) || defined(__DOXYGEN__)
332 char *name;
333#endif
334};
335
345
355void smp_rx_remove_invalid(struct smp_transport *zst, void *arg);
356
362void smp_rx_clear(struct smp_transport *zst);
363
370
379
389
393
394#ifdef __cplusplus
395}
396#endif
397
398#endif /* ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_SMP_H_ */
bool(* smp_transport_bridge_connect_fn)(struct smp_transport_bridge *bridge, bool direction, uint32_t mode, bool same_transport, zcbor_state_t *input_data, zcbor_state_t *output_data)
SMP transport bridge connect.
Definition smp.h:133
void(* smp_transport_ud_req_init_fn)(struct net_buf *nb, void *priv)
SMP init request buffer.
Definition smp.h:114
bool(* smp_transport_bridge_config_details_fn)(uint32_t mode, zcbor_state_t *output_data, int *rc)
SMP transport bridge config details.
Definition smp.h:201
void(* smp_transport_ud_free_fn)(void *ud)
SMP free user_data callback.
Definition smp.h:91
uint16_t(* smp_transport_get_mtu_fn)(const struct net_buf *nb)
SMP MTU query callback for transport.
Definition smp.h:64
bool(* smp_transport_bridge_modes_fn)(zcbor_state_t *output_data, int *rc)
SMP transport bridge details.
Definition smp.h:188
bool(* mgmt_client_transport_cb_t)(const struct smp_client_transport_entry *transport, void *user_data)
Callback for SMP client transports.
Definition smp.h:175
int(* smp_transport_out_fn)(struct net_buf *nb)
SMP transmit callback for transport.
Definition smp.h:46
void(* smp_transport_bridge_disconnect_fn)(struct smp_transport_bridge *bridge, bool direction)
SMP transport bridge disconnect.
Definition smp.h:148
smp_transport_type
SMP transport type for client registration.
Definition smp.h:296
void smp_rx_clear(struct smp_transport *zst)
Used to clear pending queued requests for an SMP transport.
struct smp_transport * smp_client_transport_get(int smpt_type)
Discover a registered SMP transport client object.
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:104
int(* smp_transport_ud_copy_fn)(struct net_buf *dst, const struct net_buf *src)
SMP copy user_data callback.
Definition smp.h:79
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.
int(* smp_transport_bridge_out_fn)(const struct smp_transport_bridge *bridge, struct net_buf *nb, bool direction)
SMP transport bridge output data.
Definition smp.h:164
bool smp_client_transport_foreach(mgmt_client_transport_cb_t user_cb, void *user_data)
Iterate over SMP client/transports.
int smp_transport_init(struct smp_transport *smpt)
Initializes a Zephyr SMP transport object.
void smp_client_transport_register(struct smp_client_transport_entry *entry)
Register a Zephyr SMP transport object for client.
@ SMP_RAW_SERIAL_TRANSPORT
SMP raw serial (not SMP over console).
Definition smp.h:300
@ SMP_UDP_IPV6_TRANSPORT
SMP UDP IPv6.
Definition smp.h:308
@ SMP_SPI_TRANSPORT
SMP SPI.
Definition smp.h:312
@ SMP_SHELL_TRANSPORT
SMP shell.
Definition smp.h:304
@ SMP_BLUETOOTH_TRANSPORT
SMP bluetooth.
Definition smp.h:302
@ SMP_USER_DEFINED_TRANSPORT
IDs up to 63 reserved for future in-tree transports.
Definition smp.h:317
@ SMP_SERIAL_TRANSPORT
SMP serial.
Definition smp.h:298
@ SMP_UDP_IPV4_TRANSPORT
SMP UDP IPv4.
Definition smp.h:306
@ SMP_LORAWAN_TRANSPORT
SMP LoRaWAN.
Definition smp.h:310
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
Public kernel APIs.
#define bool
Definition stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Kernel FIFO structure.
Definition kernel.h:2951
A structure used to submit work.
Definition kernel.h:4649
Network buffer representation.
Definition net_buf.h:1054
SMP Client transport structure.
Definition smp.h:323
int smpt_type
Transport type.
Definition smp.h:328
char * name
Transport name, used for transport mgmt (or NULL to omit).
Definition smp.h:332
sys_snode_t node
Definition smp.h:324
struct smp_transport * smpt
Transport structure pointer.
Definition smp.h:326
Function pointers of SMP transport functions, if a handler is NULL then it is not supported/implement...
Definition smp.h:208
smp_transport_ud_req_init_fn ud_init
Transport's request buffer init function.
Definition smp.h:229
smp_transport_bridge_config_details_fn bridge_config_details
Transport get config details function.
Definition smp.h:246
smp_transport_bridge_connect_fn bridge_connect
Transport connect bridge to another transport function.
Definition smp.h:233
smp_transport_bridge_modes_fn bridge_modes
Transport get modes function.
Definition smp.h:243
smp_transport_query_valid_check_fn query_valid_check
Transport's check function for if a query is valid.
Definition smp.h:226
smp_transport_bridge_out_fn bridge_output
Transport send data over bridged connection function.
Definition smp.h:239
smp_transport_out_fn output
Transport's send function.
Definition smp.h:210
smp_transport_bridge_disconnect_fn bridge_disconnect
Transport disconnect bridge function.
Definition smp.h:236
smp_transport_ud_free_fn ud_free
Transport buffer user_data free function.
Definition smp.h:223
uint16_t(* get_mtu)(const struct net_buf *nb)
Transport's get-MTU function.
Definition smp.h:217
smp_transport_ud_copy_fn ud_copy
Transport buffer user_data copy function.
Definition smp.h:220
Bridged transport context.
Definition smp.h:276
uint8_t status
Status of the bridge: 0 for no bridge (free), 1 for bridged (in use).
Definition smp.h:278
struct smp_transport * outgoing_transport
The outgoing transport, (MCUmgr operating in client mode on device) which accepts read and write resp...
Definition smp.h:290
struct smp_transport * incoming_transport
The incoming transport, (MCUmgr operating in server mode on device) which accepts read and write requ...
Definition smp.h:284
SMP transport object for sending SMP responses.
Definition smp.h:254
struct k_work work
Definition smp.h:256
struct k_fifo fifo
Definition smp.h:259
struct smp_transport_api_t functions
Definition smp.h:262