1 /* SPDX-License-Identifier: GPL-2.0 */
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2019-2020 Linaro Ltd.
6 #ifndef _IPA_ENDPOINT_H_
7 #define _IPA_ENDPOINT_H_
9 #include <linux/types.h>
10 #include <linux/workqueue.h>
11 #include <linux/if_ether.h>
20 struct ipa_gsi_endpoint_data;
22 /* Non-zero granularity of counter used to implement aggregation timeout */
23 #define IPA_AGGR_GRANULARITY 500 /* microseconds */
25 #define IPA_MTU ETH_DATA_LEN
27 enum ipa_endpoint_name {
28 IPA_ENDPOINT_AP_COMMAND_TX,
29 IPA_ENDPOINT_AP_LAN_RX,
30 IPA_ENDPOINT_AP_MODEM_TX,
31 IPA_ENDPOINT_AP_MODEM_RX,
32 IPA_ENDPOINT_MODEM_COMMAND_TX,
33 IPA_ENDPOINT_MODEM_LAN_TX,
34 IPA_ENDPOINT_MODEM_LAN_RX,
35 IPA_ENDPOINT_MODEM_AP_TX,
36 IPA_ENDPOINT_MODEM_AP_RX,
37 IPA_ENDPOINT_MODEM_DL_NLO_TX,
38 IPA_ENDPOINT_COUNT, /* Number of names (not an index) */
41 #define IPA_ENDPOINT_MAX 32 /* Max supported by driver */
44 * struct ipa_endpoint_tx - Endpoint configuration for TX endpoints
45 * @seq_type: primary packet processing sequencer type
46 * @seq_rep_type: sequencer type for replication processing
47 * @status_endpoint: endpoint to which status elements are sent
49 * The @status_endpoint is only valid if the endpoint's @status_enable
52 struct ipa_endpoint_tx {
53 enum ipa_seq_type seq_type;
54 enum ipa_seq_rep_type seq_rep_type;
55 enum ipa_endpoint_name status_endpoint;
59 * struct ipa_endpoint_rx - Endpoint configuration for RX endpoints
60 * @buffer_size: requested receive buffer size (bytes)
61 * @pad_align: power-of-2 boundary to which packet payload is aligned
62 * @aggr_time_limit: time before aggregation closes (microseconds)
63 * @aggr_hard_limit: whether aggregation closes before or after boundary
64 * @aggr_close_eof: whether aggregation closes on end-of-frame
65 * @holb_drop: whether to drop packets to avoid head-of-line blocking
67 * The actual size of the receive buffer is rounded up if necessary
68 * to be a power-of-2 number of pages.
70 * With each packet it transfers, the IPA hardware can perform certain
71 * transformations of its packet data. One of these is adding pad bytes
72 * to the end of the packet data so the result ends on a power-of-2 boundary.
74 * It is also able to aggregate multiple packets into a single receive buffer.
75 * Aggregation is "open" while a buffer is being filled, and "closes" when
76 * certain criteria are met.
78 * A time limit can be specified to close aggregation. Aggregation will be
79 * closed if this period passes after data is first written into a receive
80 * buffer. If not specified, no time limit is imposed.
82 * Insufficient space available in the receive buffer can close aggregation.
83 * The aggregation byte limit defines the point (in units of 1024 bytes) in
84 * the buffer where aggregation closes. With a "soft" aggregation limit,
85 * aggregation closes when a packet written to the buffer *crosses* that
86 * aggregation limit. With a "hard" aggregation limit, aggregation will
87 * close *before* writing a packet that would cross that boundary.
89 struct ipa_endpoint_rx {
99 * struct ipa_endpoint_config - IPA endpoint hardware configuration
100 * @resource_group: resource group to assign endpoint to
101 * @checksum: whether checksum offload is enabled
102 * @qmap: whether endpoint uses QMAP protocol
103 * @aggregation: whether endpoint supports aggregation
104 * @status_enable: whether endpoint uses status elements
105 * @dma_mode: whether endpoint operates in DMA mode
106 * @dma_endpoint: peer endpoint, if operating in DMA mode
107 * @tx: TX-specific endpoint information (see above)
108 * @rx: RX-specific endpoint information (see above)
110 struct ipa_endpoint_config {
117 enum ipa_endpoint_name dma_endpoint;
119 struct ipa_endpoint_tx tx;
120 struct ipa_endpoint_rx rx;
125 * enum ipa_replenish_flag: RX buffer replenish flags
127 * @IPA_REPLENISH_ENABLED: Whether receive buffer replenishing is enabled
128 * @IPA_REPLENISH_ACTIVE: Whether replenishing is underway
129 * @IPA_REPLENISH_COUNT: Number of defined replenish flags
131 enum ipa_replenish_flag {
132 IPA_REPLENISH_ENABLED,
133 IPA_REPLENISH_ACTIVE,
134 IPA_REPLENISH_COUNT, /* Number of flags (must be last) */
138 * struct ipa_endpoint - IPA endpoint information
140 * @ee_id: Execution environmnent endpoint is associated with
141 * @channel_id: GSI channel used by the endpoint
142 * @endpoint_id: IPA endpoint number
143 * @toward_ipa: Endpoint direction (true = TX, false = RX)
144 * @config: Default endpoint configuration
145 * @trans_tre_max: Maximum number of TRE descriptors per transaction
146 * @evt_ring_id: GSI event ring used by the endpoint
147 * @netdev: Network device pointer, if endpoint uses one
148 * @replenish_flags: Replenishing state flags
149 * @replenish_count: Total number of replenish transactions committed
150 * @replenish_work: Work item used for repeated replenish failures
152 struct ipa_endpoint {
154 enum gsi_ee_id ee_id;
158 struct ipa_endpoint_config config;
163 /* Net device this endpoint is associated with, if any */
164 struct net_device *netdev;
166 /* Receive buffer replenishing for RX endpoints */
167 DECLARE_BITMAP(replenish_flags, IPA_REPLENISH_COUNT);
169 struct delayed_work replenish_work; /* global wq */
172 void ipa_endpoint_modem_hol_block_clear_all(struct ipa *ipa);
174 void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable);
176 int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa);
178 int ipa_endpoint_skb_tx(struct ipa_endpoint *endpoint, struct sk_buff *skb);
180 int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint);
181 void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint);
183 void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint);
184 void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint);
186 void ipa_endpoint_suspend(struct ipa *ipa);
187 void ipa_endpoint_resume(struct ipa *ipa);
189 void ipa_endpoint_setup(struct ipa *ipa);
190 void ipa_endpoint_teardown(struct ipa *ipa);
192 int ipa_endpoint_config(struct ipa *ipa);
193 void ipa_endpoint_deconfig(struct ipa *ipa);
195 void ipa_endpoint_default_route_set(struct ipa *ipa, u32 endpoint_id);
196 void ipa_endpoint_default_route_clear(struct ipa *ipa);
198 u32 ipa_endpoint_init(struct ipa *ipa, u32 count,
199 const struct ipa_gsi_endpoint_data *data);
200 void ipa_endpoint_exit(struct ipa *ipa);
202 void ipa_endpoint_trans_complete(struct ipa_endpoint *ipa,
203 struct gsi_trans *trans);
204 void ipa_endpoint_trans_release(struct ipa_endpoint *ipa,
205 struct gsi_trans *trans);
207 #endif /* _IPA_ENDPOINT_H_ */