Skip to content

Commit

Permalink
Merge pull request #226 from azure-rtos/feature/tsn
Browse files Browse the repository at this point in the history
Add Time sensitive networking (TSN) support.

1. Generic link layer support
2. Virtual local area network (VLAN)
3. Multiple registration protocol (MRP)
    3.1 Multiple VLAN registration protocol (MVRP)
    3.2 Multiple Stream registration protocol (MSRP)
4. Stream reservation protocol (SRP)
5. Credit based shaper (CBS/Qav)
6. Time aware shaper (TAS/Qbv)
7. Frame preemption (FPE/Qbu)
  • Loading branch information
TiejunMS authored Dec 27, 2023
2 parents fceacf6 + 2e65f69 commit 94ccd95
Show file tree
Hide file tree
Showing 70 changed files with 20,239 additions and 2,897 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ jobs:
cmake_path: ./test/cmake/web
result_affix: Web
skip_deploy: true
PTP:
permissions:
contents: read
issues: read
checks: write
pull-requests: write
pages: write
id-token: write
uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master
with:
build_script: ./scripts/build_ptp.sh
test_script: ./scripts/test_ptp.sh
cmake_path: ./test/cmake/ptp
result_affix: PTP
skip_deploy: true
MQTT:
permissions:
contents: read
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/nx_secure)
# Utility components
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/utility)

# Link layer
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tsn)

# If the user provided an override, copy it to the custom directory
if (NOT NX_USER_FILE)
message(STATUS "Using default nx_user.h file")
Expand Down
5,053 changes: 2,752 additions & 2,301 deletions addons/BSD/nxd_bsd.c

Large diffs are not rendered by default.

69 changes: 68 additions & 1 deletion addons/BSD/nxd_bsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/* BSD DEFINITIONS RELEASE */
/* */
/* nxd_bsd.h PORTABLE C */
/* 6.3.0 */
/* 6.x */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
Expand Down Expand Up @@ -54,6 +54,10 @@
/* added option to enable */
/* native APIs with prefix, */
/* resulting in version 6.3.0 */
/* xx-xx-xxxx Yanwu Cai Modified comment(s), and */
/* added support of recvmsg, */
/* added nx_link to raw socket,*/
/* resulting in version 6.x */
/* */
/**************************************************************************/

Expand Down Expand Up @@ -171,6 +175,10 @@ extern "C" {
packet. */
#endif

#ifndef NX_BSD_IFNAMSIZE
#define NX_BSD_IFNAMSIZE 32
#endif

/* Define configurable options for BSD extended options. */


Expand Down Expand Up @@ -254,6 +262,7 @@ extern "C" {
#define nx_bsd_listen listen
#define nx_bsd_recvfrom recvfrom
#define nx_bsd_recv recv
#define nx_bsd_recvmsg recvmsg
#define nx_bsd_sendto sendto
#define nx_bsd_send send
#define nx_bsd_select select
Expand Down Expand Up @@ -382,6 +391,8 @@ extern "C" {
#define FIONBIO 0x5421 /* Enables socket non blocking option for the ioctl() command */
#endif

#define SIOCGIFINDEX 0x8933 /* Get if_index from name */
#define SIOCGIFHWADDR 0x8927 /* Get hardware address */

/* Define the minimal TCP socket listen backlog value. */
#ifndef NX_BSD_TCP_LISTEN_MIN_BACKLOG
Expand Down Expand Up @@ -550,6 +561,7 @@ extern "C" {

#define SOL_SOCKET 1 /* Define the socket option category. */
#define IPPROTO_IP 2 /* Define the IP option category. */
#define SOL_PACKET 3 /* Define the packet option category. */
#define SO_MIN 1 /* Minimum Socket option ID */
#define SO_DEBUG 1 /* Debugging information is being recorded.*/
#define SO_REUSEADDR 2 /* Enable reuse of local addresses in the time wait state */
Expand Down Expand Up @@ -594,7 +606,11 @@ extern "C" {
#define IP_RAW_IPV6_HDRINCL 36 /* Transmitted buffer over IPv6 socket contains IPv6 header. */
#define IP_OPTION_MAX IP_RAW_IPV6_HDRINCL

#define PACKET_ADD_MEMBERSHIP 41
#define PACKET_DROP_MEMBERSHIP 42
#define PACKET_OPTION_MAX PACKET_DROP_MEMBERSHIP

#define PACKET_MR_MULTICAST 1

/*
* User-settable options (used with setsockopt).
Expand Down Expand Up @@ -707,6 +723,56 @@ struct nx_bsd_ip_mreq
imr_interface; /* The interface to use for this group. */
};

#ifdef NX_BSD_RAW_SUPPORT

struct nx_bsd_packet_mreq
{
INT mr_ifindex;
USHORT mr_type;
USHORT mr_alen;
UCHAR mr_address[8];
};

#define ETH_ALEN 6
#define ETHERTYPE_VLAN 0x8100

struct nx_bsd_ether_header
{
UCHAR ether_dhost[ETH_ALEN];
UCHAR ether_shost[ETH_ALEN];
USHORT ether_type;
};

struct nx_bsd_ifreq {
CHAR ifr_name[NX_BSD_IFNAMSIZE];
union {
struct nx_bsd_sockaddr ifru_addr;
struct nx_bsd_sockaddr ifru_hwaddr;
SHORT ifru_flags;
INT ifru_ivalue;
} ifr_ifru;
};

#define ifr_hwaddr ifr_ifru.ifru_hwaddr
#define ifr_ifindex ifr_ifru.ifru_ivalue
#endif



struct nx_bsd_iovec {
void *iov_base;
size_t iov_len;
};

struct nx_bsd_msghdr {
void *msg_name;
nx_bsd_socklen_t msg_namelen;
struct nx_bsd_iovec *msg_iov;
size_t msg_iovlen;
void *msg_control;
size_t msg_controllen;
int msg_flags;
};

/* Define additional BSD data structures for supporting socket options. */

Expand Down Expand Up @@ -964,6 +1030,7 @@ VOID nx_bsd_raw_receive_notify(NX_IP *ip_ptr, UINT bsd_socket_index);
UINT nx_bsd_socket_set_inherited_settings(UINT master_sock_id, UINT secondary_sock_id);
INT nx_bsd_recvfrom(INT sockID, CHAR *buffer, INT buffersize, INT flags,struct nx_bsd_sockaddr *fromAddr, INT *fromAddrLen);
INT nx_bsd_recv(INT sockID, VOID *rcvBuffer, INT bufferLength, INT flags);
INT nx_bsd_recvmsg(INT sockID, struct nx_bsd_msghdr *msg, INT flags);
INT nx_bsd_sendto(INT sockID, CHAR *msg, INT msgLength, INT flags, struct nx_bsd_sockaddr *destAddr, INT destAddrLen);
INT nx_bsd_send(INT sockID, const CHAR *msg, INT msgLength, INT flags);
INT nx_bsd_select(INT nfds, nx_bsd_fd_set *readfds, nx_bsd_fd_set *writefds, nx_bsd_fd_set *exceptfds, struct nx_bsd_timeval *timeout);
Expand Down
Loading

0 comments on commit 94ccd95

Please sign in to comment.