1 /**
2  * Copyright (c) 2018 Linaro
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_WIFI_ESWIFI_ESWIFI_OFFLOAD_H_
8 #define ZEPHYR_DRIVERS_WIFI_ESWIFI_ESWIFI_OFFLOAD_H_
9 
10 #include <zephyr/net/net_offload.h>
11 #include "eswifi.h"
12 
13 #define ESWIFI_OFFLOAD_MAX_SOCKETS 4
14 
15 enum eswifi_transport_type {
16 	ESWIFI_TRANSPORT_TCP,
17 	ESWIFI_TRANSPORT_UDP,
18 	ESWIFI_TRANSPORT_UDP_LITE,
19 	ESWIFI_TRANSPORT_TCP_SSL,
20 };
21 
22 enum eswifi_socket_state {
23 	ESWIFI_SOCKET_STATE_NONE,
24 	ESWIFI_SOCKET_STATE_CONNECTING,
25 	ESWIFI_SOCKET_STATE_CONNECTED,
26 	ESWIFI_SOCKET_STATE_ACCEPTING,
27 };
28 
29 struct eswifi_off_socket {
30 	uint8_t index;
31 	enum eswifi_transport_type type;
32 	enum eswifi_socket_state state;
33 	struct net_context *context;
34 	net_context_recv_cb_t recv_cb;
35 	net_context_connect_cb_t conn_cb;
36 	net_context_send_cb_t send_cb;
37 	net_tcp_accept_cb_t accept_cb;
38 	void *recv_data;
39 	void *conn_data;
40 	void *send_data;
41 	void *accept_data;
42 	struct net_pkt *tx_pkt;
43 	struct k_work connect_work;
44 	struct k_work send_work;
45 	struct k_work_delayable read_work;
46 	struct sockaddr peer_addr;
47 	struct k_sem read_sem;
48 	struct k_sem accept_sem;
49 	uint16_t port;
50 	bool is_server;
51 	int usage;
52 	struct k_fifo fifo;
53 	struct net_pkt *prev_pkt_rem;
54 };
55 #endif
56