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 /** Internet Protocol (IP) */ 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_ip.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _nx_ip_auxiliary_packet_pool_set PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Yuxin Zhou, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function assigns an auxiliary packet pool to IP instance. */ 44 /* Note in order to utilize the auxiliary packet pool feature, the */ 45 /* symbol NX_ENABLE_DUAL_PACKET_POOL must be defined when building */ 46 /* NetX Duo library. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* ip_ptr Pointer to IP control block */ 51 /* auxiliary_pool Pointer to auxiliary packet */ 52 /* pool */ 53 /* */ 54 /* OUTPUT */ 55 /* */ 56 /* status Completion status */ 57 /* */ 58 /* CALLS */ 59 /* */ 60 /* tx_mutex_get Get protection mutex */ 61 /* tx_mutex_put Put protection mutex */ 62 /* */ 63 /* CALLED BY */ 64 /* */ 65 /* Application */ 66 /* */ 67 /* RELEASE HISTORY */ 68 /* */ 69 /* DATE NAME DESCRIPTION */ 70 /* */ 71 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 72 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 73 /* resulting in version 6.1 */ 74 /* */ 75 /**************************************************************************/ _nx_ip_auxiliary_packet_pool_set(NX_IP * ip_ptr,NX_PACKET_POOL * auxiliary_pool)76UINT _nx_ip_auxiliary_packet_pool_set(NX_IP *ip_ptr, NX_PACKET_POOL *auxiliary_pool) 77 { 78 79 #ifdef NX_ENABLE_DUAL_PACKET_POOL 80 TX_INTERRUPT_SAVE_AREA 81 82 83 /* Disable interrupts. */ 84 TX_DISABLE 85 86 /* Choose a packet pool with smaller payload size as auxiliary packet pool. */ 87 if (auxiliary_pool -> nx_packet_pool_payload_size > ip_ptr -> nx_ip_default_packet_pool -> nx_packet_pool_payload_size) 88 { 89 ip_ptr -> nx_ip_default_packet_pool = auxiliary_pool; 90 } 91 else 92 { 93 ip_ptr -> nx_ip_auxiliary_packet_pool = auxiliary_pool; 94 } 95 96 /* Restore interrupts. */ 97 TX_RESTORE 98 99 /* Return success to the caller. */ 100 return(NX_SUCCESS); 101 102 #else /* !NX_ENABLE_DUAL_PACKET_POOL */ 103 NX_PARAMETER_NOT_USED(ip_ptr); 104 NX_PARAMETER_NOT_USED(auxiliary_pool); 105 106 return(NX_NOT_SUPPORTED); 107 108 #endif /* NX_ENABLE_DUAL_PACKET_POOL */ 109 } 110 111