Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.13 179 lines 5.4 kB view raw
1/* 2 * Copyright (C) 2014 Texas Instruments Incorporated 3 * Authors: Sandeep Nair <sandeep_n@ti.com 4 * Cyril Chemparathy <cyril@ti.com 5 Santosh Shilimkar <santosh.shilimkar@ti.com> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation version 2. 10 * 11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any 12 * kind, whether express or implied; without even the implied warranty 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 */ 16 17#ifndef __SOC_TI_KEYSTONE_NAVIGATOR_DMA_H__ 18#define __SOC_TI_KEYSTONE_NAVIGATOR_DMA_H__ 19 20/* 21 * PKTDMA descriptor manipulation macros for host packet descriptor 22 */ 23#define MASK(x) (BIT(x) - 1) 24#define KNAV_DMA_DESC_PKT_LEN_MASK MASK(22) 25#define KNAV_DMA_DESC_PKT_LEN_SHIFT 0 26#define KNAV_DMA_DESC_PS_INFO_IN_SOP BIT(22) 27#define KNAV_DMA_DESC_PS_INFO_IN_DESC 0 28#define KNAV_DMA_DESC_TAG_MASK MASK(8) 29#define KNAV_DMA_DESC_SAG_HI_SHIFT 24 30#define KNAV_DMA_DESC_STAG_LO_SHIFT 16 31#define KNAV_DMA_DESC_DTAG_HI_SHIFT 8 32#define KNAV_DMA_DESC_DTAG_LO_SHIFT 0 33#define KNAV_DMA_DESC_HAS_EPIB BIT(31) 34#define KNAV_DMA_DESC_NO_EPIB 0 35#define KNAV_DMA_DESC_PSLEN_SHIFT 24 36#define KNAV_DMA_DESC_PSLEN_MASK MASK(6) 37#define KNAV_DMA_DESC_ERR_FLAG_SHIFT 20 38#define KNAV_DMA_DESC_ERR_FLAG_MASK MASK(4) 39#define KNAV_DMA_DESC_PSFLAG_SHIFT 16 40#define KNAV_DMA_DESC_PSFLAG_MASK MASK(4) 41#define KNAV_DMA_DESC_RETQ_SHIFT 0 42#define KNAV_DMA_DESC_RETQ_MASK MASK(14) 43#define KNAV_DMA_DESC_BUF_LEN_MASK MASK(22) 44#define KNAV_DMA_DESC_EFLAGS_MASK MASK(4) 45#define KNAV_DMA_DESC_EFLAGS_SHIFT 20 46 47#define KNAV_DMA_NUM_EPIB_WORDS 4 48#define KNAV_DMA_NUM_PS_WORDS 16 49#define KNAV_DMA_NUM_SW_DATA_WORDS 4 50#define KNAV_DMA_FDQ_PER_CHAN 4 51 52/* Tx channel scheduling priority */ 53enum knav_dma_tx_priority { 54 DMA_PRIO_HIGH = 0, 55 DMA_PRIO_MED_H, 56 DMA_PRIO_MED_L, 57 DMA_PRIO_LOW 58}; 59 60/* Rx channel error handling mode during buffer starvation */ 61enum knav_dma_rx_err_mode { 62 DMA_DROP = 0, 63 DMA_RETRY 64}; 65 66/* Rx flow size threshold configuration */ 67enum knav_dma_rx_thresholds { 68 DMA_THRESH_NONE = 0, 69 DMA_THRESH_0 = 1, 70 DMA_THRESH_0_1 = 3, 71 DMA_THRESH_0_1_2 = 7 72}; 73 74/* Descriptor type */ 75enum knav_dma_desc_type { 76 DMA_DESC_HOST = 0, 77 DMA_DESC_MONOLITHIC = 2 78}; 79 80/** 81 * struct knav_dma_tx_cfg: Tx channel configuration 82 * @filt_einfo: Filter extended packet info 83 * @filt_pswords: Filter PS words present 84 * @knav_dma_tx_priority: Tx channel scheduling priority 85 */ 86struct knav_dma_tx_cfg { 87 bool filt_einfo; 88 bool filt_pswords; 89 enum knav_dma_tx_priority priority; 90}; 91 92/** 93 * struct knav_dma_rx_cfg: Rx flow configuration 94 * @einfo_present: Extended packet info present 95 * @psinfo_present: PS words present 96 * @knav_dma_rx_err_mode: Error during buffer starvation 97 * @knav_dma_desc_type: Host or Monolithic desc 98 * @psinfo_at_sop: PS word located at start of packet 99 * @sop_offset: Start of packet offset 100 * @dst_q: Destination queue for a given flow 101 * @thresh: Rx flow size threshold 102 * @fdq[]: Free desc Queue array 103 * @sz_thresh0: RX packet size threshold 0 104 * @sz_thresh1: RX packet size threshold 1 105 * @sz_thresh2: RX packet size threshold 2 106 */ 107struct knav_dma_rx_cfg { 108 bool einfo_present; 109 bool psinfo_present; 110 enum knav_dma_rx_err_mode err_mode; 111 enum knav_dma_desc_type desc_type; 112 bool psinfo_at_sop; 113 unsigned int sop_offset; 114 unsigned int dst_q; 115 enum knav_dma_rx_thresholds thresh; 116 unsigned int fdq[KNAV_DMA_FDQ_PER_CHAN]; 117 unsigned int sz_thresh0; 118 unsigned int sz_thresh1; 119 unsigned int sz_thresh2; 120}; 121 122/** 123 * struct knav_dma_cfg: Pktdma channel configuration 124 * @sl_cfg: Slave configuration 125 * @tx: Tx channel configuration 126 * @rx: Rx flow configuration 127 */ 128struct knav_dma_cfg { 129 enum dma_transfer_direction direction; 130 union { 131 struct knav_dma_tx_cfg tx; 132 struct knav_dma_rx_cfg rx; 133 } u; 134}; 135 136/** 137 * struct knav_dma_desc: Host packet descriptor layout 138 * @desc_info: Descriptor information like id, type, length 139 * @tag_info: Flow tag info written in during RX 140 * @packet_info: Queue Manager, policy, flags etc 141 * @buff_len: Buffer length in bytes 142 * @buff: Buffer pointer 143 * @next_desc: For chaining the descriptors 144 * @orig_len: length since 'buff_len' can be overwritten 145 * @orig_buff: buff pointer since 'buff' can be overwritten 146 * @epib: Extended packet info block 147 * @psdata: Protocol specific 148 * @sw_data: Software private data not touched by h/w 149 */ 150struct knav_dma_desc { 151 __le32 desc_info; 152 __le32 tag_info; 153 __le32 packet_info; 154 __le32 buff_len; 155 __le32 buff; 156 __le32 next_desc; 157 __le32 orig_len; 158 __le32 orig_buff; 159 __le32 epib[KNAV_DMA_NUM_EPIB_WORDS]; 160 __le32 psdata[KNAV_DMA_NUM_PS_WORDS]; 161 u32 sw_data[KNAV_DMA_NUM_SW_DATA_WORDS]; 162} ____cacheline_aligned; 163 164#if IS_ENABLED(CONFIG_KEYSTONE_NAVIGATOR_DMA) 165void *knav_dma_open_channel(struct device *dev, const char *name, 166 struct knav_dma_cfg *config); 167void knav_dma_close_channel(void *channel); 168#else 169static inline void *knav_dma_open_channel(struct device *dev, const char *name, 170 struct knav_dma_cfg *config) 171{ 172 return (void *) NULL; 173} 174static inline void knav_dma_close_channel(void *channel) 175{} 176 177#endif 178 179#endif /* __SOC_TI_KEYSTONE_NAVIGATOR_DMA_H__ */