Merge tag 'io_uring-5.7-2020-04-09' of git://git.kernel.dk/linux-block
[platform/kernel/linux-rpi.git] / drivers / net / ipa / ipa_endpoint.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2019-2020 Linaro Ltd.
5  */
6 #ifndef _IPA_ENDPOINT_H_
7 #define _IPA_ENDPOINT_H_
8
9 #include <linux/types.h>
10 #include <linux/workqueue.h>
11 #include <linux/if_ether.h>
12
13 #include "gsi.h"
14 #include "ipa_reg.h"
15
16 struct net_device;
17 struct sk_buff;
18
19 struct ipa;
20 struct ipa_gsi_endpoint_data;
21
22 /* Non-zero granularity of counter used to implement aggregation timeout */
23 #define IPA_AGGR_GRANULARITY            500     /* microseconds */
24
25 #define IPA_MTU                 ETH_DATA_LEN
26
27 enum ipa_endpoint_name {
28         IPA_ENDPOINT_AP_MODEM_TX        = 0,
29         IPA_ENDPOINT_MODEM_LAN_TX,
30         IPA_ENDPOINT_MODEM_COMMAND_TX,
31         IPA_ENDPOINT_AP_COMMAND_TX,
32         IPA_ENDPOINT_MODEM_AP_TX,
33         IPA_ENDPOINT_AP_LAN_RX,
34         IPA_ENDPOINT_AP_MODEM_RX,
35         IPA_ENDPOINT_MODEM_AP_RX,
36         IPA_ENDPOINT_MODEM_LAN_RX,
37         IPA_ENDPOINT_COUNT,     /* Number of names (not an index) */
38 };
39
40 #define IPA_ENDPOINT_MAX                32      /* Max supported by driver */
41
42 /**
43  * struct ipa_endpoint - IPA endpoint information
44  * @client:     Client associated with the endpoint
45  * @channel_id: EP's GSI channel
46  * @evt_ring_id: EP's GSI channel event ring
47  */
48 struct ipa_endpoint {
49         struct ipa *ipa;
50         enum ipa_seq_type seq_type;
51         enum gsi_ee_id ee_id;
52         u32 channel_id;
53         u32 endpoint_id;
54         bool toward_ipa;
55         const struct ipa_endpoint_config_data *data;
56
57         u32 trans_tre_max;      /* maximum descriptors per transaction */
58         u32 evt_ring_id;
59
60         /* Net device this endpoint is associated with, if any */
61         struct net_device *netdev;
62
63         /* Receive buffer replenishing for RX endpoints */
64         bool replenish_enabled;
65         u32 replenish_ready;
66         atomic_t replenish_saved;
67         atomic_t replenish_backlog;
68         struct delayed_work replenish_work;             /* global wq */
69 };
70
71 void ipa_endpoint_modem_hol_block_clear_all(struct ipa *ipa);
72
73 void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable);
74
75 int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa);
76
77 int ipa_endpoint_skb_tx(struct ipa_endpoint *endpoint, struct sk_buff *skb);
78
79 int ipa_endpoint_stop(struct ipa_endpoint *endpoint);
80
81 void ipa_endpoint_exit_one(struct ipa_endpoint *endpoint);
82
83 int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint);
84 void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint);
85
86 void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint);
87 void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint);
88
89 void ipa_endpoint_suspend(struct ipa *ipa);
90 void ipa_endpoint_resume(struct ipa *ipa);
91
92 void ipa_endpoint_setup(struct ipa *ipa);
93 void ipa_endpoint_teardown(struct ipa *ipa);
94
95 int ipa_endpoint_config(struct ipa *ipa);
96 void ipa_endpoint_deconfig(struct ipa *ipa);
97
98 void ipa_endpoint_default_route_set(struct ipa *ipa, u32 endpoint_id);
99 void ipa_endpoint_default_route_clear(struct ipa *ipa);
100
101 u32 ipa_endpoint_init(struct ipa *ipa, u32 count,
102                       const struct ipa_gsi_endpoint_data *data);
103 void ipa_endpoint_exit(struct ipa *ipa);
104
105 void ipa_endpoint_trans_complete(struct ipa_endpoint *ipa,
106                                  struct gsi_trans *trans);
107 void ipa_endpoint_trans_release(struct ipa_endpoint *ipa,
108                                 struct gsi_trans *trans);
109
110 #endif /* _IPA_ENDPOINT_H_ */