xref: /openbmc/linux/drivers/net/ipa/ipa_gsi.c (revision 15e3ae36)
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 
7 #include <linux/types.h>
8 
9 #include "gsi_trans.h"
10 #include "ipa.h"
11 #include "ipa_endpoint.h"
12 #include "ipa_data.h"
13 
14 void ipa_gsi_trans_complete(struct gsi_trans *trans)
15 {
16 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
17 
18 	ipa_endpoint_trans_complete(ipa->channel_map[trans->channel_id], trans);
19 }
20 
21 void ipa_gsi_trans_release(struct gsi_trans *trans)
22 {
23 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
24 
25 	ipa_endpoint_trans_release(ipa->channel_map[trans->channel_id], trans);
26 }
27 
28 void ipa_gsi_channel_tx_queued(struct gsi *gsi, u32 channel_id, u32 count,
29 			       u32 byte_count)
30 {
31 	struct ipa *ipa = container_of(gsi, struct ipa, gsi);
32 	struct ipa_endpoint *endpoint;
33 
34 	endpoint = ipa->channel_map[channel_id];
35 	if (endpoint->netdev)
36 		netdev_sent_queue(endpoint->netdev, byte_count);
37 }
38 
39 void ipa_gsi_channel_tx_completed(struct gsi *gsi, u32 channel_id, u32 count,
40 				  u32 byte_count)
41 {
42 	struct ipa *ipa = container_of(gsi, struct ipa, gsi);
43 	struct ipa_endpoint *endpoint;
44 
45 	endpoint = ipa->channel_map[channel_id];
46 	if (endpoint->netdev)
47 		netdev_completed_queue(endpoint->netdev, count, byte_count);
48 }
49 
50 /* Indicate whether an endpoint config data entry is "empty" */
51 bool ipa_gsi_endpoint_data_empty(const struct ipa_gsi_endpoint_data *data)
52 {
53 	return data->ee_id == GSI_EE_AP && !data->channel.tlv_count;
54 }
55