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_interface_physical_address_set PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function sets the physical address to driver. */
44 /* */
45 /* INPUT */
46 /* */
47 /* ip_ptr IP control block pointer */
48 /* interface_index Index of interface */
49 /* physical_msw Physical address MSW */
50 /* physical_lsw Physical address LSW */
51 /* update_driver Update driver or not */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* status Completion status */
56 /* */
57 /* CALLS */
58 /* */
59 /* tx_mutex_get Get protection mutex */
60 /* tx_mutex_put Put protection mutex */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* Application Code */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
71 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
72 /* resulting in version 6.1 */
73 /* */
74 /**************************************************************************/
_nx_ip_interface_physical_address_set(NX_IP * ip_ptr,UINT interface_index,ULONG physical_msw,ULONG physical_lsw,UINT update_driver)75 UINT _nx_ip_interface_physical_address_set(NX_IP *ip_ptr, UINT interface_index,
76 ULONG physical_msw, ULONG physical_lsw, UINT update_driver)
77 {
78 NX_INTERFACE *if_ptr = &(ip_ptr -> nx_ip_interface[interface_index]);
79 NX_IP_DRIVER driver_request;
80
81 /* Initialize the status. */
82 driver_request.nx_ip_driver_status = NX_SUCCESS;
83
84 /* Obtain the IP internal mutex before calling the driver. */
85 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
86
87 if (update_driver == NX_TRUE)
88 {
89
90 /* Set driver request. */
91 driver_request.nx_ip_driver_physical_address_msw = physical_msw;
92 driver_request.nx_ip_driver_physical_address_lsw = physical_lsw;
93 driver_request.nx_ip_driver_ptr = ip_ptr;
94 driver_request.nx_ip_driver_command = NX_LINK_SET_PHYSICAL_ADDRESS;
95 driver_request.nx_ip_driver_interface = if_ptr;
96
97 /* Call the link driver to set physical address. */
98 (if_ptr -> nx_interface_link_driver_entry)(&driver_request);
99 }
100
101 /* Check status. */
102 if (driver_request.nx_ip_driver_status == NX_SUCCESS)
103 {
104
105 /* Set physical address to interface. */
106 if_ptr -> nx_interface_physical_address_msw = physical_msw;
107 if_ptr -> nx_interface_physical_address_lsw = physical_lsw;
108 }
109
110 /* Release the IP internal mutex. */
111 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
112
113 /* Return completion status. */
114 return(driver_request.nx_ip_driver_status);
115 }
116
117