diff --git a/doc/zephyr.doxyfile.in b/doc/zephyr.doxyfile.in index 05b541c517d..9245f598925 100644 --- a/doc/zephyr.doxyfile.in +++ b/doc/zephyr.doxyfile.in @@ -279,9 +279,7 @@ TAB_SIZE = 8 # with the commands \{ and \} for these it is advised to use the version @{ and # @} or use a double escape (\\{ and \\}) -ALIASES = "rst=\verbatim embed:rst:leading-asterisk" \ - endrst=\endverbatim \ - "kconfig{1}=\htmlonly \1 \endhtmlonly \xmlonly embed:rst:inline :kconfig:option:`\1` \endxmlonly" \ +ALIASES = "kconfig{1}=\verbatim \1 \endverbatim" \ "req{1}=\ref ZEPH_\1 \"ZEPH-\1\"" \ "satisfy{1}=\xrefitem satisfy \"Satisfies requirement\" \"Requirement Implementation\" \1" \ "verify{1}=\xrefitem verify \"Verifies requirement\" \"Requirement Verification\" \1" \ @@ -289,14 +287,14 @@ ALIASES = "rst=\verbatim embed:rst:leading-asterisk" \ "kconfig_dep{2}=\attention Available only when the following Kconfig options are enabled: \kconfig{\1}, \kconfig{\2}." \ "kconfig_dep{3}=\attention Available only when the following Kconfig options are enabled: \kconfig{\1}, \kconfig{\2}, \kconfig{\3}." \ "funcprops=\par \"Function properties (list may not be complete)\"" \ - "reschedule=\htmlonly reschedule \endhtmlonly \xmlonly embed:rst:inline :ref:`api_term_reschedule` \endxmlonly" \ - "sleep=\htmlonly sleep \endhtmlonly \xmlonly embed:rst:inline :ref:`api_term_sleep` \endxmlonly" \ - "no_wait=\htmlonly no-wait \endhtmlonly \xmlonly embed:rst:inline :ref:`api_term_no-wait` \endxmlonly" \ - "isr_ok=\htmlonly isr-ok \endhtmlonly \xmlonly embed:rst:inline :ref:`api_term_isr-ok` \endxmlonly" \ - "pre_kernel_ok=\htmlonly pre-kernel-ok \endhtmlonly \xmlonly embed:rst:inline :ref:`api_term_pre-kernel-ok` \endxmlonly" \ - "async=\htmlonly async \endhtmlonly \xmlonly embed:rst:inline :ref:`api_term_async` \endxmlonly" \ + "reschedule=\qualifier reschedule" \ + "sleep=\qualifier sleep" \ + "no_wait=\qualifier no-wait" \ + "isr_ok=\qualifier isr-ok" \ + "pre_kernel_ok=\qualifier pre-kernel-ok" \ + "async=\qualifier async" \ "atomic_api=As for all atomic APIs, includes a full/sequentially-consistent memory barrier (where applicable)." \ - "supervisor=\htmlonly supervisor \endhtmlonly \xmlonly embed:rst:inline :ref:`api_term_supervisor` \endxmlonly" + "supervisor=\qualifier supervisor" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For diff --git a/include/zephyr/bluetooth/audio/bap.h b/include/zephyr/bluetooth/audio/bap.h index 83159bed43f..9f13cd2fdee 100644 --- a/include/zephyr/bluetooth/audio/bap.h +++ b/include/zephyr/bluetooth/audio/bap.h @@ -640,13 +640,13 @@ struct bt_bap_unicast_server_register_param { /** * @brief Sink Count to register. * - * Should be in range [0, @kconfig{CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT}] + * Should be in range 0 to @kconfig{CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT} */ uint8_t snk_cnt; /** @brief Source Count to register. * - * Should be in range [0, @kconfig{CONFIG_BT_ASCS_MAX_ASE_SRC_COUNT}] + * Should be in range 0 to @kconfig{CONFIG_BT_ASCS_MAX_ASE_SRC_COUNT} */ uint8_t src_cnt; }; diff --git a/include/zephyr/bluetooth/l2cap.h b/include/zephyr/bluetooth/l2cap.h index 0117da5ebb9..d3a49f9b3a9 100644 --- a/include/zephyr/bluetooth/l2cap.h +++ b/include/zephyr/bluetooth/l2cap.h @@ -18,6 +18,7 @@ * @{ */ +#include #include #include @@ -552,6 +553,26 @@ int bt_l2cap_ecred_chan_connect(struct bt_conn *conn, */ int bt_l2cap_ecred_chan_reconfigure(struct bt_l2cap_chan **chans, uint16_t mtu); +/** @brief Reconfigure Enhanced Credit Based L2CAP channels + * + * Experimental API to reconfigure with explicit MPS and MTU values. + * + * Reconfigure up to 5 L2CAP channels. Channels must be from the same bt_conn. + * Once reconfiguration is completed each channel reconfigured() callback will + * be called. MTU cannot be decreased on any of provided channels. + * + * @kconfig_dep{CONFIG_BT_L2CAP_RECONFIGURE_EXPLICIT} + * + * @param chans Array of channel objects. Null-terminated. Elements after the + * first 5 are silently ignored. + * @param mtu Channel MTU to reconfigure to. + * @param mps Channel MPS to reconfigure to. + * + * @return 0 in case of success or negative value in case of error. + */ +int bt_l2cap_ecred_chan_reconfigure_explicit(struct bt_l2cap_chan **chans, uint16_t mtu, + uint16_t mps); + /** @brief Connect L2CAP channel * * Connect L2CAP channel by PSM, once the connection is completed channel diff --git a/include/zephyr/net/socket.h b/include/zephyr/net/socket.h index 34211d83759..05351c8cef0 100644 --- a/include/zephyr/net/socket.h +++ b/include/zephyr/net/socket.h @@ -333,13 +333,11 @@ __syscall void *zsock_get_context_object(int sock); * @brief Create a network socket * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html * for normative description. - * This function is also exposed as ``socket()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `socket()` + * if @kconfig{CONFIG_POSIX_API} is defined. * * If CONFIG_USERSPACE is enabled, the caller will be granted access to the * context object associated with the returned file descriptor. @@ -352,13 +350,11 @@ __syscall int zsock_socket(int family, int type, int proto); * @brief Create an unnamed pair of connected sockets * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * https://pubs.opengroup.org/onlinepubs/009695399/functions/socketpair.html * for normative description. - * This function is also exposed as ``socketpair()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `socketpair()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_socketpair(int family, int type, int proto, int *sv); @@ -366,12 +362,10 @@ __syscall int zsock_socketpair(int family, int type, int proto, int *sv); * @brief Close a network socket * * @details - * @rst * Close a network socket. - * This function is also exposed as ``close()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined (in which case it - * may conflict with generic POSIX ``close()`` function). - * @endrst + * This function is also exposed as `close()` + * if @kconfig{CONFIG_POSIX_API} is defined (in which case it + * may conflict with generic POSIX `close()` function). */ __syscall int zsock_close(int sock); @@ -379,14 +373,12 @@ __syscall int zsock_close(int sock); * @brief Shutdown socket send/receive operations * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html * for normative description, but currently this function has no effect in * Zephyr and provided solely for compatibility with existing code. - * This function is also exposed as ``shutdown()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `shutdown()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_shutdown(int sock, int how); @@ -394,13 +386,11 @@ __syscall int zsock_shutdown(int sock, int how); * @brief Bind a socket to a local network address * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html * for normative description. - * This function is also exposed as ``bind()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `bind()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_bind(int sock, const struct sockaddr *addr, socklen_t addrlen); @@ -409,13 +399,11 @@ __syscall int zsock_bind(int sock, const struct sockaddr *addr, * @brief Connect a socket to a peer network address * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html * for normative description. - * This function is also exposed as ``connect()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `connect()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_connect(int sock, const struct sockaddr *addr, socklen_t addrlen); @@ -424,13 +412,11 @@ __syscall int zsock_connect(int sock, const struct sockaddr *addr, * @brief Set up a STREAM socket to accept peer connections * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html * for normative description. - * This function is also exposed as ``listen()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `listen()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_listen(int sock, int backlog); @@ -438,13 +424,11 @@ __syscall int zsock_listen(int sock, int backlog); * @brief Accept a connection on listening socket * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html * for normative description. - * This function is also exposed as ``accept()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `accept()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_accept(int sock, struct sockaddr *addr, socklen_t *addrlen); @@ -452,13 +436,11 @@ __syscall int zsock_accept(int sock, struct sockaddr *addr, socklen_t *addrlen); * @brief Send data to an arbitrary network address * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html * for normative description. - * This function is also exposed as ``sendto()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `sendto()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall ssize_t zsock_sendto(int sock, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, @@ -468,13 +450,11 @@ __syscall ssize_t zsock_sendto(int sock, const void *buf, size_t len, * @brief Send data to a connected peer * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html * for normative description. - * This function is also exposed as ``send()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `send()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ static inline ssize_t zsock_send(int sock, const void *buf, size_t len, int flags) @@ -486,13 +466,11 @@ static inline ssize_t zsock_send(int sock, const void *buf, size_t len, * @brief Send data to an arbitrary network address * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html * for normative description. - * This function is also exposed as ``sendmsg()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `sendmsg()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall ssize_t zsock_sendmsg(int sock, const struct msghdr *msg, int flags); @@ -501,13 +479,11 @@ __syscall ssize_t zsock_sendmsg(int sock, const struct msghdr *msg, * @brief Receive data from an arbitrary network address * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html * for normative description. - * This function is also exposed as ``recvfrom()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `recvfrom()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall ssize_t zsock_recvfrom(int sock, void *buf, size_t max_len, int flags, struct sockaddr *src_addr, @@ -517,13 +493,11 @@ __syscall ssize_t zsock_recvfrom(int sock, void *buf, size_t max_len, * @brief Receive a message from an arbitrary network address * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html * for normative description. - * This function is also exposed as ``recvmsg()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `recvmsg()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall ssize_t zsock_recvmsg(int sock, struct msghdr *msg, int flags); @@ -531,13 +505,11 @@ __syscall ssize_t zsock_recvmsg(int sock, struct msghdr *msg, int flags); * @brief Receive data from a connected peer * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html * for normative description. - * This function is also exposed as ``recv()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `recv()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ static inline ssize_t zsock_recv(int sock, void *buf, size_t max_len, int flags) @@ -549,13 +521,11 @@ static inline ssize_t zsock_recv(int sock, void *buf, size_t max_len, * @brief Control blocking/non-blocking mode of a socket * * @details - * @rst * This functions allow to (only) configure a socket for blocking or * non-blocking operation (O_NONBLOCK). - * This function is also exposed as ``fcntl()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined (in which case - * it may conflict with generic POSIX ``fcntl()`` function). - * @endrst + * This function is also exposed as `fcntl()` + * if @kconfig{CONFIG_POSIX_API} is defined (in which case + * it may conflict with generic POSIX `fcntl()` function). */ __syscall int zsock_fcntl_impl(int sock, int cmd, int flags); @@ -584,18 +554,16 @@ static inline int zsock_fcntl_wrapper(int sock, int cmd, ...) * @brief Control underlying socket parameters * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * https://pubs.opengroup.org/onlinepubs/9699919799/functions/ioctl.html * for normative description. * This function enables querying or manipulating underlying socket parameters. - * Currently supported @p request values include ``ZFD_IOCTL_FIONBIO``, and - * ``ZFD_IOCTL_FIONREAD``, to set non-blocking mode, and query the number of + * Currently supported @p request values include `ZFD_IOCTL_FIONBIO`, and + * `ZFD_IOCTL_FIONREAD`, to set non-blocking mode, and query the number of * bytes available to read, respectively. - * This function is also exposed as ``ioctl()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined (in which case - * it may conflict with generic POSIX ``ioctl()`` function). - * @endrst + * This function is also exposed as `ioctl()` + * if @kconfig{CONFIG_POSIX_API} is defined (in which case + * it may conflict with generic POSIX `ioctl()` function). */ __syscall int zsock_ioctl_impl(int sock, unsigned long request, va_list ap); @@ -621,14 +589,12 @@ static inline int zsock_ioctl_wrapper(int sock, unsigned long request, ...) * @brief Efficiently poll multiple sockets for events * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html * for normative description. - * This function is also exposed as ``poll()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined (in which case - * it may conflict with generic POSIX ``poll()`` function). - * @endrst + * This function is also exposed as `poll()` + * if @kconfig{CONFIG_POSIX_API} is defined (in which case + * it may conflict with generic POSIX `poll()` function). */ __syscall int zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout); @@ -636,16 +602,14 @@ __syscall int zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout); * @brief Get various socket options * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html * for normative description. In Zephyr this function supports a subset of * socket options described by POSIX, but also some additional options * available in Linux (some options are dummy and provided to ease porting * of existing code). - * This function is also exposed as ``getsockopt()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `getsockopt()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_getsockopt(int sock, int level, int optname, void *optval, socklen_t *optlen); @@ -654,16 +618,14 @@ __syscall int zsock_getsockopt(int sock, int level, int optname, * @brief Set various socket options * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html * for normative description. In Zephyr this function supports a subset of * socket options described by POSIX, but also some additional options * available in Linux (some options are dummy and provided to ease porting * of existing code). - * This function is also exposed as ``setsockopt()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `setsockopt()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_setsockopt(int sock, int level, int optname, const void *optval, socklen_t optlen); @@ -672,13 +634,11 @@ __syscall int zsock_setsockopt(int sock, int level, int optname, * @brief Get peer name * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html * for normative description. - * This function is also exposed as ``getpeername()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `getpeername()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_getpeername(int sock, struct sockaddr *addr, socklen_t *addrlen); @@ -687,13 +647,11 @@ __syscall int zsock_getpeername(int sock, struct sockaddr *addr, * @brief Get socket name * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html * for normative description. - * This function is also exposed as ``getsockname()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `getsockname()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_getsockname(int sock, struct sockaddr *addr, socklen_t *addrlen); @@ -702,13 +660,11 @@ __syscall int zsock_getsockname(int sock, struct sockaddr *addr, * @brief Get local host name * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html * for normative description. - * This function is also exposed as ``gethostname()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `gethostname()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_gethostname(char *buf, size_t len); @@ -716,13 +672,11 @@ __syscall int zsock_gethostname(char *buf, size_t len); * @brief Convert network address from internal to numeric ASCII form * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html * for normative description. - * This function is also exposed as ``inet_ntop()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `inet_ntop()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ static inline char *zsock_inet_ntop(sa_family_t family, const void *src, char *dst, size_t size) @@ -734,13 +688,11 @@ static inline char *zsock_inet_ntop(sa_family_t family, const void *src, * @brief Convert network address from numeric ASCII form to internal representation * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_pton.html * for normative description. - * This function is also exposed as ``inet_pton()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `inet_pton()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ __syscall int zsock_inet_pton(sa_family_t family, const char *src, void *dst); @@ -779,13 +731,11 @@ __syscall int z_zsock_getaddrinfo_internal(const char *host, * @brief Resolve a domain name to one or more network addresses * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html * for normative description. - * This function is also exposed as ``getaddrinfo()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `getaddrinfo()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ int zsock_getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints, @@ -795,13 +745,11 @@ int zsock_getaddrinfo(const char *host, const char *service, * @brief Free results returned by zsock_getaddrinfo() * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/freeaddrinfo.html * for normative description. - * This function is also exposed as ``freeaddrinfo()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `freeaddrinfo()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ void zsock_freeaddrinfo(struct zsock_addrinfo *ai); @@ -809,13 +757,11 @@ void zsock_freeaddrinfo(struct zsock_addrinfo *ai); * @brief Convert zsock_getaddrinfo() error code to textual message * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/gai_strerror.html * for normative description. - * This function is also exposed as ``gai_strerror()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `gai_strerror()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ const char *zsock_gai_strerror(int errcode); @@ -846,13 +792,11 @@ const char *zsock_gai_strerror(int errcode); * @brief Resolve a network address to a domain name or ASCII address * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html * for normative description. - * This function is also exposed as ``getnameinfo()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `getnameinfo()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ int zsock_getnameinfo(const struct sockaddr *addr, socklen_t addrlen, char *host, socklen_t hostlen, diff --git a/include/zephyr/net/socket_select.h b/include/zephyr/net/socket_select.h index 5fca2950d6a..b0754d5fc86 100644 --- a/include/zephyr/net/socket_select.h +++ b/include/zephyr/net/socket_select.h @@ -35,17 +35,15 @@ typedef struct zsock_fd_set { * @brief Legacy function to poll multiple sockets for events * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html * for normative description. This function is provided to ease porting of * existing code and not recommended for usage due to its inefficiency, * use zsock_poll() instead. In Zephyr this function works only with * sockets, not arbitrary file descriptors. - * This function is also exposed as ``select()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined (in which case - * it may conflict with generic POSIX ``select()`` function). - * @endrst + * This function is also exposed as `select()` + * if @kconfig{CONFIG_POSIX_API} is defined (in which case + * it may conflict with generic POSIX `select()` function). */ __syscall int zsock_select(int nfds, zsock_fd_set *readfds, zsock_fd_set *writefds, @@ -59,13 +57,11 @@ __syscall int zsock_select(int nfds, zsock_fd_set *readfds, * @brief Initialize (clear) fd_set * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html * for normative description. - * This function is also exposed as ``FD_ZERO()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `FD_ZERO()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ void ZSOCK_FD_ZERO(zsock_fd_set *set); @@ -73,13 +69,11 @@ void ZSOCK_FD_ZERO(zsock_fd_set *set); * @brief Check whether socket is a member of fd_set * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html * for normative description. - * This function is also exposed as ``FD_ISSET()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `FD_ISSET()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set); @@ -87,13 +81,11 @@ int ZSOCK_FD_ISSET(int fd, zsock_fd_set *set); * @brief Remove socket from fd_set * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html * for normative description. - * This function is also exposed as ``FD_CLR()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `FD_CLR()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ void ZSOCK_FD_CLR(int fd, zsock_fd_set *set); @@ -101,13 +93,11 @@ void ZSOCK_FD_CLR(int fd, zsock_fd_set *set); * @brief Add socket to fd_set * * @details - * @rst - * See `POSIX.1-2017 article - * `__ + * See POSIX.1-2017 article + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html * for normative description. - * This function is also exposed as ``FD_SET()`` - * if :kconfig:option:`CONFIG_POSIX_API` is defined. - * @endrst + * This function is also exposed as `FD_SET()` + * if @kconfig{CONFIG_POSIX_API} is defined. */ void ZSOCK_FD_SET(int fd, zsock_fd_set *set); diff --git a/subsys/bluetooth/host/Kconfig.l2cap b/subsys/bluetooth/host/Kconfig.l2cap index ed1428aade7..b886dc9d740 100644 --- a/subsys/bluetooth/host/Kconfig.l2cap +++ b/subsys/bluetooth/host/Kconfig.l2cap @@ -70,4 +70,12 @@ config BT_L2CAP_SEG_RECV This API enforces conformance with L2CAP TS, but is otherwise as flexible and semantically simple as possible. +config BT_L2CAP_RECONFIGURE_EXPLICIT + bool "L2CAP Explicit reconfigure API [EXPERIMENTAL]" + select EXPERIMENTAL + help + + Enable API for explicit reconfiguration of an L2CAP channel's MTU and + MPS. + endmenu diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 8747eae4791..23c65cebf36 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -41,6 +41,7 @@ LOG_MODULE_REGISTER(bt_l2cap, CONFIG_BT_L2CAP_LOG_LEVEL); #define L2CAP_LE_MIN_MTU 23 #define L2CAP_ECRED_MIN_MTU 64 +#define L2CAP_ECRED_MIN_MPS 64 #define L2CAP_LE_MAX_CREDITS (CONFIG_BT_BUF_ACL_RX_COUNT - 1) @@ -2553,6 +2554,7 @@ static void l2cap_chan_le_recv_seg_direct(struct bt_l2cap_le_chan *chan, struct if (seg->len > sdu_remaining) { LOG_WRN("L2CAP RX PDU total exceeds SDU"); bt_l2cap_chan_disconnect(&chan->chan); + return; } /* Commit receive. */ @@ -3027,6 +3029,105 @@ int bt_l2cap_ecred_chan_reconfigure(struct bt_l2cap_chan **chans, uint16_t mtu) return 0; } +#if defined(CONFIG_BT_L2CAP_RECONFIGURE_EXPLICIT) +int bt_l2cap_ecred_chan_reconfigure_explicit(struct bt_l2cap_chan **chans, uint16_t mtu, + uint16_t mps) +{ + struct bt_l2cap_ecred_reconf_req *req; + struct bt_conn *conn = NULL; + struct bt_l2cap_le_chan *ch; + struct net_buf *buf; + bool multiple_chan; + uint8_t ident; + int i; + + LOG_DBG("chans %p mtu 0x%04x mps 0x%04x", chans, mtu, mps); + + if (!chans) { + return -EINVAL; + } + + if (chans[0] == NULL) { + return -EINVAL; + } + + if (mps < L2CAP_ECRED_MIN_MPS || mps > BT_L2CAP_RX_MTU) { + return -EINVAL; + } + + multiple_chan = chans[1] != NULL; + + for (i = 0; i < L2CAP_ECRED_CHAN_MAX_PER_REQ; i++) { + if (!chans[i]) { + break; + } + + /* validate that all channels are from same connection */ + if (conn) { + if (conn != chans[i]->conn) { + return -EINVAL; + } + } else { + conn = chans[i]->conn; + } + + /* validate MTU is not decreased */ + if (mtu < BT_L2CAP_LE_CHAN(chans[i])->rx.mtu) { + return -EINVAL; + } + + /* MPS is not allowed to decrease when reconfiguring multiple channels. + * Core Specification 3.A.4.27 v6.0 + */ + if (multiple_chan && mps < BT_L2CAP_LE_CHAN(chans[i])->rx.mps) { + return -EINVAL; + } + } + + if (!conn) { + return -ENOTCONN; + } + + if (conn->type != BT_CONN_TYPE_LE) { + return -EINVAL; + } + + /* allow only 1 request at time */ + if (l2cap_find_pending_reconf(conn)) { + return -EBUSY; + } + + ident = get_ident(); + + buf = l2cap_create_le_sig_pdu(BT_L2CAP_ECRED_RECONF_REQ, ident, + sizeof(*req) + (i * sizeof(uint16_t))); + if (!buf) { + return -ENOMEM; + } + + req = net_buf_add(buf, sizeof(*req)); + req->mtu = sys_cpu_to_le16(mtu); + req->mps = sys_cpu_to_le16(mps); + + for (int j = 0; j < i; j++) { + ch = BT_L2CAP_LE_CHAN(chans[j]); + + ch->ident = ident; + ch->pending_rx_mtu = mtu; + + net_buf_add_le16(buf, ch->rx.cid); + }; + + /* We set the RTX timer on one of the supplied channels, but when the + * request resolves or times out we will act on all the channels in the + * supplied array, using the ident field to find them. + */ + l2cap_chan_send_req(chans[0], buf, L2CAP_CONN_TIMEOUT); + + return 0; +} +#endif /* defined(CONFIG_BT_L2CAP_RECONFIGURE_EXPLICIT) */ + #endif /* defined(CONFIG_BT_L2CAP_ECRED) */ int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, diff --git a/tests/bluetooth/tester/prj.conf b/tests/bluetooth/tester/prj.conf index ba5a40d078b..db254d1f668 100644 --- a/tests/bluetooth/tester/prj.conf +++ b/tests/bluetooth/tester/prj.conf @@ -16,6 +16,9 @@ CONFIG_BT_BONDABLE=y CONFIG_BT_ATT_PREPARE_COUNT=12 CONFIG_BT_GATT_CLIENT=y CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y +CONFIG_BT_L2CAP_TX_MTU=255 +CONFIG_BT_L2CAP_SEG_RECV=y +CONFIG_BT_L2CAP_RECONFIGURE_EXPLICIT=y CONFIG_BT_DEVICE_NAME="Tester" CONFIG_BT_DEVICE_NAME_MAX=32 CONFIG_BT_DEVICE_NAME_DYNAMIC=y @@ -25,15 +28,14 @@ CONFIG_BT_L2CAP_ECRED=y CONFIG_BT_EATT_MAX=5 CONFIG_BT_FILTER_ACCEPT_LIST=y CONFIG_BT_EATT_AUTO_CONNECT=n -CONFIG_BT_MAX_CONN=2 -CONFIG_BT_MAX_PAIRED=2 +CONFIG_BT_MAX_CONN=3 +CONFIG_BT_MAX_PAIRED=3 CONFIG_BT_GATT_NOTIFY_MULTIPLE=y CONFIG_BT_ATT_RETRY_ON_SEC_ERR=n CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_PER_ADV_SYNC=y -CONFIG_BT_BUF_ACL_RX_SIZE=100 CONFIG_BT_RX_STACK_SIZE=4096 CONFIG_BT_TESTING=y @@ -54,3 +56,9 @@ CONFIG_BT_DIS_SERIAL_NUMBER=y CONFIG_BT_DIS_FW_REV=y CONFIG_BT_DIS_HW_REV=y CONFIG_BT_DIS_SW_REV=y + +CONFIG_BT_BUF_EVT_RX_COUNT=16 +CONFIG_BT_BUF_EVT_RX_SIZE=255 +CONFIG_BT_BUF_CMD_TX_SIZE=255 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_BUF_ACL_RX_SIZE=255 diff --git a/tests/bluetooth/tester/src/btp_l2cap.c b/tests/bluetooth/tester/src/btp_l2cap.c index 69c438f7f6f..6b62811eaf3 100644 --- a/tests/bluetooth/tester/src/btp_l2cap.c +++ b/tests/bluetooth/tester/src/btp_l2cap.c @@ -19,14 +19,15 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL); #include "btp/btp.h" -#define DATA_MTU_INITIAL 128 -#define DATA_MTU 256 -#define DATA_BUF_SIZE BT_L2CAP_SDU_BUF_SIZE(DATA_MTU) +#define L2CAP_MPS 96 +#define DATA_MTU (3 * L2CAP_MPS) +#define DATA_MTU_INITIAL (2 * L2CAP_MPS) + #define CHANNELS 2 #define SERVERS 1 -NET_BUF_POOL_FIXED_DEFINE(data_pool, CHANNELS, DATA_BUF_SIZE, CONFIG_BT_CONN_TX_USER_DATA_SIZE, - NULL); +NET_BUF_POOL_FIXED_DEFINE(data_pool, CHANNELS, BT_L2CAP_SDU_BUF_SIZE(DATA_MTU), + CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL); static bool authorize_flag; static uint8_t req_keysize; @@ -36,18 +37,51 @@ static struct channel { struct bt_l2cap_le_chan le; bool in_use; bool hold_credit; +#if defined(CONFIG_BT_L2CAP_SEG_RECV) + unsigned int pending_credits; + uint8_t recv_cb_buf[DATA_MTU + sizeof(struct btp_l2cap_data_received_ev)]; +#else struct net_buf *pending_credit; +#endif } channels[CHANNELS]; /* TODO Extend to support multiple servers */ static struct bt_l2cap_server servers[SERVERS]; +#if defined(CONFIG_BT_L2CAP_SEG_RECV) +static void seg_recv_cb(struct bt_l2cap_chan *l2cap_chan, size_t sdu_len, off_t seg_offset, + struct net_buf_simple *seg) +{ + struct btp_l2cap_data_received_ev *ev; + struct bt_l2cap_le_chan *l2cap_le_chan = + CONTAINER_OF(l2cap_chan, struct bt_l2cap_le_chan, chan); + struct channel *chan = CONTAINER_OF(l2cap_le_chan, struct channel, le); + + ev = (void *)chan->recv_cb_buf; + memcpy(&ev->data[seg_offset], seg->data, seg->len); + + /* complete SDU received */ + if (seg_offset + seg->len == sdu_len) { + ev->chan_id = chan->chan_id; + ev->data_length = sys_cpu_to_le16(sdu_len); + + tester_event(BTP_SERVICE_ID_L2CAP, BTP_L2CAP_EV_DATA_RECEIVED, chan->recv_cb_buf, + sizeof(*ev) + sdu_len); + } + + if (chan->hold_credit) { + chan->pending_credits++; + } else { + bt_l2cap_chan_give_credits(l2cap_chan, 1); + } +} +#else static struct net_buf *alloc_buf_cb(struct bt_l2cap_chan *chan) { return net_buf_alloc(&data_pool, K_FOREVER); } -static uint8_t recv_cb_buf[DATA_BUF_SIZE + sizeof(struct btp_l2cap_data_received_ev)]; +static uint8_t recv_cb_buf[DATA_MTU + sizeof(struct btp_l2cap_data_received_ev)]; static int recv_cb(struct bt_l2cap_chan *l2cap_chan, struct net_buf *buf) { @@ -73,6 +107,7 @@ static int recv_cb(struct bt_l2cap_chan *l2cap_chan, struct net_buf *buf) return 0; } +#endif static void connected_cb(struct bt_l2cap_chan *l2cap_chan) { @@ -111,11 +146,13 @@ static void disconnected_cb(struct bt_l2cap_chan *l2cap_chan) struct channel *chan = CONTAINER_OF(l2cap_le_chan, struct channel, le); struct bt_conn_info info; +#if !defined(CONFIG_BT_L2CAP_SEG_RECV) /* release netbuf on premature disconnection */ if (chan->pending_credit) { net_buf_unref(chan->pending_credit); chan->pending_credit = NULL; } +#endif (void)memset(&ev, 0, sizeof(struct btp_l2cap_disconnected_ev)); @@ -160,12 +197,16 @@ static void reconfigured_cb(struct bt_l2cap_chan *l2cap_chan) #endif static const struct bt_l2cap_chan_ops l2cap_ops = { - .alloc_buf = alloc_buf_cb, - .recv = recv_cb, - .connected = connected_cb, - .disconnected = disconnected_cb, +#if defined(CONFIG_BT_L2CAP_SEG_RECV) + .seg_recv = seg_recv_cb, +#else + .alloc_buf = alloc_buf_cb, + .recv = recv_cb, +#endif + .connected = connected_cb, + .disconnected = disconnected_cb, #if defined(CONFIG_BT_L2CAP_ECRED) - .reconfigured = reconfigured_cb, + .reconfigured = reconfigured_cb, #endif }; @@ -222,10 +263,15 @@ static uint8_t connect(const void *cmd, uint16_t cmd_len, } chan->le.chan.ops = &l2cap_ops; chan->le.rx.mtu = mtu; +#if defined(CONFIG_BT_L2CAP_SEG_RECV) + chan->le.rx.mps = L2CAP_MPS; +#endif rp->chan_id[i] = chan->chan_id; allocated_channels[i] = &chan->le.chan; chan->hold_credit = cp->options & BTP_L2CAP_CONNECT_OPT_HOLD_CREDIT; + + bt_l2cap_chan_give_credits(&chan->le.chan, 1); } if (cp->num == 1 && !ecfc) { @@ -289,6 +335,7 @@ static uint8_t reconfigure(const void *cmd, uint16_t cmd_len, { const struct btp_l2cap_reconfigure_cmd *cp = cmd; uint16_t mtu; + uint16_t mps; struct bt_conn *conn; int err; struct bt_l2cap_chan *reconf_channels[CHANNELS + 1] = {}; @@ -321,7 +368,8 @@ static uint8_t reconfigure(const void *cmd, uint16_t cmd_len, return BTP_STATUS_FAILED; } - err = bt_l2cap_ecred_chan_reconfigure(reconf_channels, mtu); + mps = MIN(L2CAP_MPS, BT_L2CAP_RX_MTU); + err = bt_l2cap_ecred_chan_reconfigure_explicit(reconf_channels, mtu, mps); if (err) { bt_conn_unref(conn); return BTP_STATUS_FAILED; @@ -454,9 +502,14 @@ static int accept(struct bt_conn *conn, struct bt_l2cap_server *server, chan->le.chan.ops = &l2cap_ops; chan->le.rx.mtu = DATA_MTU_INITIAL; +#if defined(CONFIG_BT_L2CAP_SEG_RECV) + chan->le.rx.mps = L2CAP_MPS; +#endif *l2cap_chan = &chan->le.chan; + bt_l2cap_chan_give_credits(&chan->le.chan, 1); + return 0; } @@ -524,7 +577,15 @@ static uint8_t credits(const void *cmd, uint16_t cmd_len, if (!chan->in_use) { return BTP_STATUS_FAILED; } +#if defined(CONFIG_BT_L2CAP_SEG_RECV) + if (chan->pending_credits) { + if (bt_l2cap_chan_give_credits(&chan->le.chan, chan->pending_credits) < 0) { + return BTP_STATUS_FAILED; + } + chan->pending_credits = 0; + } +#else if (chan->pending_credit) { if (bt_l2cap_chan_recv_complete(&chan->le.chan, chan->pending_credit) < 0) { @@ -533,6 +594,7 @@ static uint8_t credits(const void *cmd, uint16_t cmd_len, chan->pending_credit = NULL; } +#endif return BTP_STATUS_SUCCESS; }