Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
0004  * Copyright (C) 2019-2020 Linaro Ltd.
0005  */
0006 #ifndef _IPA_CMD_H_
0007 #define _IPA_CMD_H_
0008 
0009 #include <linux/types.h>
0010 #include <linux/dma-direction.h>
0011 
0012 struct sk_buff;
0013 struct scatterlist;
0014 
0015 struct ipa;
0016 struct ipa_mem;
0017 struct gsi_trans;
0018 struct gsi_channel;
0019 
0020 /**
0021  * enum ipa_cmd_opcode: IPA immediate commands
0022  *
0023  * @IPA_CMD_IP_V4_FILTER_INIT:  Initialize IPv4 filter table
0024  * @IPA_CMD_IP_V6_FILTER_INIT:  Initialize IPv6 filter table
0025  * @IPA_CMD_IP_V4_ROUTING_INIT: Initialize IPv4 routing table
0026  * @IPA_CMD_IP_V6_ROUTING_INIT: Initialize IPv6 routing table
0027  * @IPA_CMD_HDR_INIT_LOCAL: Initialize IPA-local header memory
0028  * @IPA_CMD_REGISTER_WRITE: Register write performed by IPA
0029  * @IPA_CMD_IP_PACKET_INIT: Set up next packet's destination endpoint
0030  * @IPA_CMD_DMA_SHARED_MEM: DMA command performed by IPA
0031  * @IPA_CMD_IP_PACKET_TAG_STATUS: Have next packet generate tag * status
0032  * @IPA_CMD_NONE:       Special (invalid) "not a command" value
0033  *
0034  * All immediate commands are issued using the AP command TX endpoint.
0035  */
0036 enum ipa_cmd_opcode {
0037     IPA_CMD_NONE            = 0x0,
0038     IPA_CMD_IP_V4_FILTER_INIT   = 0x3,
0039     IPA_CMD_IP_V6_FILTER_INIT   = 0x4,
0040     IPA_CMD_IP_V4_ROUTING_INIT  = 0x7,
0041     IPA_CMD_IP_V6_ROUTING_INIT  = 0x8,
0042     IPA_CMD_HDR_INIT_LOCAL      = 0x9,
0043     IPA_CMD_REGISTER_WRITE      = 0xc,
0044     IPA_CMD_IP_PACKET_INIT      = 0x10,
0045     IPA_CMD_DMA_SHARED_MEM      = 0x13,
0046     IPA_CMD_IP_PACKET_TAG_STATUS    = 0x14,
0047 };
0048 
0049 /**
0050  * ipa_cmd_table_valid() - Validate a memory region holding a table
0051  * @ipa:    - IPA pointer
0052  * @mem:    - IPA memory region descriptor
0053  * @route:  - Whether the region holds a route or filter table
0054  *
0055  * Return:  true if region is valid, false otherwise
0056  */
0057 bool ipa_cmd_table_valid(struct ipa *ipa, const struct ipa_mem *mem,
0058                 bool route);
0059 
0060 /**
0061  * ipa_cmd_data_valid() - Validate command-realted configuration is valid
0062  * @ipa:    - IPA pointer
0063  *
0064  * Return:  true if assumptions required for command are valid
0065  */
0066 bool ipa_cmd_data_valid(struct ipa *ipa);
0067 
0068 /**
0069  * ipa_cmd_pool_init() - initialize command channel pools
0070  * @channel:    AP->IPA command TX GSI channel pointer
0071  * @tre_count:  Number of pool elements to allocate
0072  *
0073  * Return:  0 if successful, or a negative error code
0074  */
0075 int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_count);
0076 
0077 /**
0078  * ipa_cmd_pool_exit() - Inverse of ipa_cmd_pool_init()
0079  * @channel:    AP->IPA command TX GSI channel pointer
0080  */
0081 void ipa_cmd_pool_exit(struct gsi_channel *channel);
0082 
0083 /**
0084  * ipa_cmd_table_init_add() - Add table init command to a transaction
0085  * @trans:  GSI transaction
0086  * @opcode: IPA immediate command opcode
0087  * @size:   Size of non-hashed routing table memory
0088  * @offset: Offset in IPA shared memory of non-hashed routing table memory
0089  * @addr:   DMA address of non-hashed table data to write
0090  * @hash_size:  Size of hashed routing table memory
0091  * @hash_offset: Offset in IPA shared memory of hashed routing table memory
0092  * @hash_addr:  DMA address of hashed table data to write
0093  *
0094  * If hash_size is 0, hash_offset and hash_addr are ignored.
0095  */
0096 void ipa_cmd_table_init_add(struct gsi_trans *trans, enum ipa_cmd_opcode opcode,
0097                 u16 size, u32 offset, dma_addr_t addr,
0098                 u16 hash_size, u32 hash_offset,
0099                 dma_addr_t hash_addr);
0100 
0101 /**
0102  * ipa_cmd_hdr_init_local_add() - Add a header init command to a transaction
0103  * @trans:  GSI transaction
0104  * @offset: Offset of header memory in IPA local space
0105  * @size:   Size of header memory
0106  * @addr:   DMA address of buffer to be written from
0107  *
0108  * Defines and fills the location in IPA memory to use for headers.
0109  */
0110 void ipa_cmd_hdr_init_local_add(struct gsi_trans *trans, u32 offset, u16 size,
0111                 dma_addr_t addr);
0112 
0113 /**
0114  * ipa_cmd_register_write_add() - Add a register write command to a transaction
0115  * @trans:  GSI transaction
0116  * @offset: Offset of register to be written
0117  * @value:  Value to be written
0118  * @mask:   Mask of bits in register to update with bits from value
0119  * @clear_full: Pipeline clear option; true means full pipeline clear
0120  */
0121 void ipa_cmd_register_write_add(struct gsi_trans *trans, u32 offset, u32 value,
0122                 u32 mask, bool clear_full);
0123 
0124 /**
0125  * ipa_cmd_dma_shared_mem_add() - Add a DMA memory command to a transaction
0126  * @trans:  GSI transaction
0127  * @offset: Offset of IPA memory to be read or written
0128  * @size:   Number of bytes of memory to be transferred
0129  * @addr:   DMA address of buffer to be read into or written from
0130  * @toward_ipa: true means write to IPA memory; false means read
0131  */
0132 void ipa_cmd_dma_shared_mem_add(struct gsi_trans *trans, u32 offset,
0133                 u16 size, dma_addr_t addr, bool toward_ipa);
0134 
0135 /**
0136  * ipa_cmd_pipeline_clear_add() - Add pipeline clear commands to a transaction
0137  * @trans:  GSI transaction
0138  */
0139 void ipa_cmd_pipeline_clear_add(struct gsi_trans *trans);
0140 
0141 /**
0142  * ipa_cmd_pipeline_clear_count() - # commands required to clear pipeline
0143  *
0144  * Return:  The number of elements to allocate in a transaction
0145  *      to hold commands to clear the pipeline
0146  */
0147 u32 ipa_cmd_pipeline_clear_count(void);
0148 
0149 /**
0150  * ipa_cmd_pipeline_clear_wait() - Wait pipeline clear to complete
0151  * @ipa:    - IPA pointer
0152  */
0153 void ipa_cmd_pipeline_clear_wait(struct ipa *ipa);
0154 
0155 /**
0156  * ipa_cmd_trans_alloc() - Allocate a transaction for the command TX endpoint
0157  * @ipa:    IPA pointer
0158  * @tre_count:  Number of elements in the transaction
0159  *
0160  * Return:  A GSI transaction structure, or a null pointer if all
0161  *      available transactions are in use
0162  */
0163 struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count);
0164 
0165 #endif /* _IPA_CMD_H_ */