1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   Multiple VLAN Registration Protocol (MVRP)                          */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    nx_mvrp.h                                              Generic      */
28 /*                                                           6.4.0        */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Yajun Xia, Microsoft Corporation                                    */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the NetX TSN MVRP component.                      */
36 /*                                                                        */
37 /*  RELEASE HISTORY                                                       */
38 /*                                                                        */
39 /*    DATE              NAME                      DESCRIPTION             */
40 /*                                                                        */
41 /*  12-31-2023     Yajun Xia               Initial Version 6.4.0          */
42 /*                                                                        */
43 /**************************************************************************/
44 
45 #ifndef NX_MVRP_H
46 #define NX_MVRP_H
47 
48 /* Determine if a C++ compiler is being used.  If so, ensure that standard
49    C is used to process the API information.  */
50 #ifdef __cplusplus
51 
52 /* Yes, C++ compiler is present.  Use standard C.  */
53 extern   "C" {
54 
55 #endif
56 
57 #include "nx_api.h"
58 #include "nx_mrp.h"
59 
60 /* Define MVRP constants. */
61 #define NX_MRP_MVRP_PROTOCOL_VERSION     (0)
62 
63 #define NX_MVRP_MAD_INDICATION_JOIN      (1)
64 #define NX_MVRP_MAD_INDICATION_LEAVE     (2)
65 
66 #define NX_MVRP_ATTRIBUTE_ARRAY_MAX_SIZE (10)
67 
68 #define NX_MVRP_ATTRIBUTE_TYPE_VLAN_ID   (1)
69 #define NX_MVRP_ATTRIBUTE_LENGTH_VLAN_ID (2)
70 
71 #define NX_MVRP_ATTRIBUTE_END_MARK_SIZE  (2)
72 
73 #define NX_MVRP_ACTION_NEW               (NX_MRP_INDICATION_NEW)
74 #define NX_MVRP_ACTION_TYPE_JOIN         (NX_MRP_INDICATION_JOIN)
75 #define NX_MVRP_ACTION_TYPE_LEAVE        (NX_MRP_INDICATION_LV)
76 
77 typedef UINT (*NX_MVRP_EVENT_CALLBACK)(NX_MRP_PARTICIPANT *participant, NX_MRP_ATTRIBUTE *attribute, UCHAR event, VOID *callback_data);
78 
79 /* MVRP structure.  */
80 typedef struct NX_MVRP_ATTRIBUTE_STRUCT
81 {
82     NX_MRP_ATTRIBUTE mrp_attribute;
83     USHORT           vlan_id;
84     UCHAR            reserved[2];
85 } NX_MVRP_ATTRIBUTE;
86 
87 typedef struct NX_MVRP_STRUCT
88 {
89     NX_MRP_PARTICIPANT     participant;
90     NX_MVRP_EVENT_CALLBACK mvrp_event_callback;
91 } NX_MVRP;
92 
93 /* Internal functions.  */
94 UINT nx_mvrp_indication_process(struct NX_MRP_STRUCT *mrp, struct NX_MRP_PARTICIPANT_STRUCT *participant, NX_MRP_ATTRIBUTE *attribute, UCHAR indication_type);
95 
96 UINT nx_mvrp_mrpdu_pack(NX_MRP *mrp, NX_MRP_PARTICIPANT *participant, NX_PACKET *packet_ptr);
97 
98 UINT nx_mvrp_mrpdu_unpack(NX_MRP *mrp, NX_MRP_PARTICIPANT *participant, NX_PACKET *packet_ptr);
99 
100 UINT nx_mvrp_attribute_find(NX_MRP *mrp, NX_MRP_PARTICIPANT *participant, NX_MRP_ATTRIBUTE **attribute_ptr, USHORT vlan_id);
101 void nx_mvrp_attribute_insert(NX_MRP *mrp, NX_MRP_PARTICIPANT *participant, NX_MRP_ATTRIBUTE *attribute);
102 UINT nx_mvrp_attribute_get(NX_MRP *mrp, NX_MRP_PARTICIPANT *participant, NX_MRP_ATTRIBUTE **attribute_ptr, USHORT vlan_id);
103 UINT nx_mvrp_action_request(NX_MRP *mrp, NX_MRP_PARTICIPANT *participant, USHORT vlan_id, UCHAR action_type);
104 UINT nx_mvrp_init(NX_MVRP *mvrp_ptr);
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
110 #endif /* NX_MVRP_H */
111 
112