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 generic APSTA functionality that chip specific files use
20 */
21
22 #include "whd_debug.h"
23 #include "whd_network_if.h"
24
25 /******************************************************
26 * * @cond Constants
27 * ******************************************************/
28
29 /******************************************************
30 * * Enumerations
31 * ******************************************************/
32
33 /******************************************************
34 ** Function Declarations
35 *******************************************************/
36
37 /******************************************************
38 * Variables Definitions
39 *****************************************************/
40
41 /******************************************************
42 * Function Definitions
43 ******************************************************/
44 /** Called by WHD to pass received data to the network stack
45 *
46 *
47 * Packets received from the Wi-Fi network by WHD are forwarded to by calling function ptr which
48 * must be implemented in the network interface. Ethernet headers
49 * are present at the start of these packet buffers.
50 *
51 * This function is called asynchronously in the context of the
52 * WHD thread whenever new data has arrived.
53 * Packet buffers are allocated within WHD, and ownership is transferred
54 * to the network stack. The network stack or application is thus
55 * responsible for releasing the packet buffers.
56 * Most packet buffering systems have a pointer to the 'current point' within
57 * the packet buffer. When this function is called, the pointer points
58 * to the start of the Ethernet header. There is other inconsequential data
59 * before the Ethernet header.
60 *
61 * It is preferable that the (whd_network_process_ethernet_data)() function simply puts
62 * the received packet on a queue for processing by another thread. This avoids the
63 * WHD thread being unnecessarily tied up which would delay other packets
64 * being transmitted or received.
65 *
66 * @param interface : The interface on which the packet was received.
67 * @param buffer : Handle of the packet which has just been received. Responsibility for
68 * releasing this buffer is transferred from WHD at this point.
69 *
70 */
whd_network_process_ethernet_data(whd_interface_t ifp,whd_buffer_t buffer)71 whd_result_t whd_network_process_ethernet_data(whd_interface_t ifp, whd_buffer_t buffer)
72 {
73 whd_driver_t whd_driver = ifp->whd_driver;
74 if (whd_driver->network_if->whd_network_process_ethernet_data)
75 {
76 whd_driver->network_if->whd_network_process_ethernet_data(ifp, buffer);
77 return WHD_SUCCESS;
78 }
79 else
80 {
81 WPRINT_WHD_INFO( ("Function pointers not provided .\n") );
82 }
83 return WHD_WLAN_NOFUNCTION;
84 }
85