File: xtrxll_base_pcie.h

package info (click to toggle)
libxtrxll 0.0.1%2Bgit20191021.3229d65-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 444 kB
  • sloc: ansic: 7,030; xml: 19; makefile: 13
file content (130 lines) | stat: -rw-r--r-- 3,685 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * Internal base pcie header file
 * Copyright (c) 2017 Sergey Kostanbaev <sergey.kostanbaev@fairwaves.co>
 * For more information, please visit: http://xtrx.io
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
#ifndef XTRXLL_BASE_PCIE_H
#define XTRXLL_BASE_PCIE_H

#include <stdbool.h>
#include "xtrxll_base.h"


/* XTRX DMA control */
enum rxdma_stat {
	RXDMA_OVF        = 31,
	RXDMA_RE         = 30,
	RXDMA_BLK_REM    = 18,
	RXDMA_BLK_READY  = 17,
	RXDMA_FERESET    = 16,
	RXDMA_FEMODE     = 14,
	RXDMA_FEFMT      = 12,
	RXDMA_BUFNO_READ = 6,
	RXDMA_BUFNO      = 0,
};


enum txdma_stat {
	/** TxDMA buffer currently requesting by the DMA core  */
	TXDMA_BUFNO_TRANS_OFF = 8,

	/** TxDMA buffer that has been transfered into the air */
	TXDMA_BUFNO_CLEARED   = 16,

	/** TxDMA buffer ready for filling */
	TXDMA_BUFNO_WR        = 24,
};


struct xtrxll_base_pcie_dma {
	struct xtrxll_base_dev base;

	unsigned cfg_rx_bufsize;
	unsigned tx_prev_burst_samples;

	//RX states
	int rx_rdsafe; ///< Number of buffers available for safe reading
	unsigned rd_block_samples; ///< Number of samples in the block (MIMO or SISO)
	unsigned rd_buf_idx;
	wts_long_t rd_cur_sample;  ///< Current timestamp (for all channels)

	unsigned tx_written;
	int tx_wrsafe;

	int tx_late_bursts;

	bool rx_owf_detected;
	bool rx_running;
};

enum {
	XTRXLL_TXBUF_SIZE_MIMO_SYMBS = 2048,
};

enum pci_ids {
	XTRX_DID_V0 = 0x7012,
	XTRX_VID_V0 = 0x10ee,
};

enum pciebase_dmarx_flags {
	PCIEDMARX_FORCE_LOG = 1,
	PCIEDMARX_NO_CNTR_UPD = 2,
	PCIEDMARX_NO_CNTR_CHECK = 4,
};


/* XTRX DMA configuration */
#define RXDMA_BUFFERS      32
#define TXDMA_BUFFERS      RXDMA_BUFFERS

#define TXDMA_MMAP_BUFF    32768
#define TXDMA_MMAP_SIZE    (TXDMA_BUFFERS * TXDMA_MMAP_BUFF)


int xtrxllpciebase_dmarx_bufsz(struct xtrxll_base_pcie_dma* dev,
								unsigned min_bytes);
int xtrxllpciebase_dmatx_bufsz(struct xtrxll_base_pcie_dma* dev,
							   unsigned min_bytes);

int xtrxllpciebase_init(struct xtrxll_base_pcie_dma* dev);

int xtrxllpciebase_dmarx_resume(struct xtrxll_base_pcie_dma* dev, int chan,
								wts_long_t nxt);

int xtrxllpciebase_dmarx_get(struct xtrxll_base_pcie_dma* dev, int chan,
							 unsigned *pbufno, wts_long_t *wts, unsigned *sz,
							 unsigned flags, unsigned icnt);

int xtrxllpciebase_dmatx_post(struct xtrxll_base_pcie_dma* dev, int chan,
							  unsigned bufno, wts_long_t wts, uint32_t samples);

int xtrxllpciebase_dmatx_get(struct xtrxll_base_pcie_dma* dev, int chan,
							 unsigned* bufno, int* late, bool diag);

int xtrxllpciebase_repeat_tx(struct xtrxll_base_pcie_dma* dev,
							 int chan, xtrxll_fe_t fmt,
							 unsigned buf_szs, xtrxll_mode_t mode);

int xtrxllpciebase_repeat_tx_start(struct xtrxll_base_pcie_dma* dev,
								   int chan, int start);

int xtrxllpciebase_dma_start(struct xtrxll_base_pcie_dma* dev, int chan,
							 const struct xtrxll_dmaop *op);

int xtrxllpciebase_dmarx_stat(struct xtrxll_base_pcie_dma* dev);

#endif //XTRXLL_BASE_PCIE_H