1 /*
2  * Copyright 2022, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /** @file
19  *  Provides prototypes / declarations for common APSTA functionality
20  */
21 #ifndef _WHD_INTERNAL_NETWORK_API_H_
22 #define _WHD_INTERNAL_NETWORK_API_H_
23 
24 #include "whd.h"
25 #include "whd_int.h"
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32 /******************************************************
33 *                      Macros
34 ******************************************************/
35 
36 /******************************************************
37 *             Structures
38 ******************************************************/
39 
40 /******************************************************
41 *             Function prototypes
42 ******************************************************/
43 /** Called by WHD to pass received data to the network stack
44  *
45  *
46  *  Packets received from the Wi-Fi network by WHD are forwarded to by calling function ptr which
47  *  must be implemented in the network interface. Ethernet headers
48  *  are present at the start of these packet buffers.
49  *
50  *  This function is called asynchronously in the context of the
51  *  WHD thread whenever new data has arrived.
52  *  Packet buffers are allocated within WHD, and ownership is transferred
53  *  to the network stack. The network stack or application is thus
54  *  responsible for releasing the packet buffers.
55  *  Most packet buffering systems have a pointer to the 'current point' within
56  *  the packet buffer. When this function is called, the pointer points
57  *  to the start of the Ethernet header. There is other inconsequential data
58  *  before the Ethernet header.
59  *
60  *  It is preferable that the (whd_network_process_ethernet_data)() function simply puts
61  *  the received packet on a queue for processing by another thread. This avoids the
62  *  WHD thread being unnecessarily tied up which would delay other packets
63  *  being transmitted or received.
64  *
65  *  @param interface : The interface on which the packet was received.
66  *  @param buffer    : Handle of the packet which has just been received. Responsibility for
67  *                    releasing this buffer is transferred from WHD at this point.
68  *
69  */
70 whd_result_t whd_network_process_ethernet_data(whd_interface_t ifp, whd_buffer_t buffer);
71 #ifdef __cplusplus
72 } /*extern "C" */
73 #endif
74 
75 #endif /* ifndef _WHD_INTERNAL_NETWORK_API_H_ */
76