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 /**   Packet Pool Management (Packet)                                     */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "nx_api.h"
28 #include "nx_packet.h"
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _nxe_packet_vlan_priority_set                       PORTABLE C      */
35 /*                                                           6.4.0        */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Yajun Xia, Microsoft Corporation                                    */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function checks for errors in packet vlan priority set call.   */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    packet_ptr                            Pointer of packet             */
47 /*    vlan_priority                         Vlan priority                 */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    status                                Actual completion status      */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    _nx_packet_vlan_priority_set          Actual packet vlan priority   */
56 /*                                            set function                */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    Application Code                                                    */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  12-31-2023     Yajun Xia                Initial Version 6.4.0         */
67 /*                                                                        */
68 /**************************************************************************/
_nxe_packet_vlan_priority_set(NX_PACKET * packet_ptr,UINT vlan_priority)69 UINT _nxe_packet_vlan_priority_set(NX_PACKET *packet_ptr, UINT vlan_priority)
70 {
71 #ifdef NX_ENABLE_VLAN
72 UINT status;
73 
74     /* Simple integrity check on the packet.  */
75     if ((packet_ptr == NX_NULL) || (packet_ptr -> nx_packet_pool_owner == NX_NULL) ||
76         ((packet_ptr -> nx_packet_pool_owner) -> nx_packet_pool_id != NX_PACKET_POOL_ID))
77     {
78         return(NX_PTR_ERROR);
79     }
80 
81     if (vlan_priority > NX_VLAN_PRIORITY_MAX)
82     {
83 
84         return(NX_INVALID_PARAMETERS);
85     }
86 
87     /* Call actual packet vlan priority set function.  */
88     status =  _nx_packet_vlan_priority_set(packet_ptr, vlan_priority);
89 
90     return(status);
91 #else
92     NX_PARAMETER_NOT_USED(packet_ptr);
93     NX_PARAMETER_NOT_USED(vlan_priority);
94 
95     return(NX_NOT_SUPPORTED);
96 #endif /* NX_ENABLE_VLAN */
97 }
98 
99