aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cxgbe/cxgbe_ofld.h
blob: 50931ed0489c0fc63fe13ad9e9519d2f2c353989 (plain)
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
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2018 Chelsio Communications.
 * All rights reserved.
 */

#ifndef _CXGBE_OFLD_H_
#define _CXGBE_OFLD_H_

#include <rte_bitmap.h>

#include "cxgbe_filter.h"

#define INIT_TP_WR(w, tid) do { \
	(w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_TP_WR) | \
				V_FW_WR_IMMDLEN(sizeof(*w) - sizeof(w->wr))); \
	(w)->wr.wr_mid = cpu_to_be32( \
				V_FW_WR_LEN16(DIV_ROUND_UP(sizeof(*w), 16)) | \
				V_FW_WR_FLOWID(tid)); \
	(w)->wr.wr_lo = cpu_to_be64(0); \
} while (0)

#define INIT_TP_WR_MIT_CPL(w, cpl, tid) do { \
	INIT_TP_WR(w, tid); \
	OPCODE_TID(w) = cpu_to_be32(MK_OPCODE_TID(cpl, tid)); \
} while (0)

#define INIT_ULPTX_WR(w, wrlen, atomic, tid) do { \
	(w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_ULPTX_WR) | \
				    V_FW_WR_ATOMIC(atomic)); \
	(w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \
				     V_FW_WR_FLOWID(tid)); \
	(w)->wr.wr_lo = cpu_to_be64(0); \
} while (0)

/*
 * Max # of ATIDs.  The absolute HW max is 16K but we keep it lower.
 */
#define MAX_ATIDS 8192U

union aopen_entry {
	void *data;
	union aopen_entry *next;
};

/*
 * Holds the size, base address, free list start, etc of filter TID.
 * The tables themselves are allocated dynamically.
 */
struct tid_info {
	void **tid_tab;
	unsigned int ntids;
	struct filter_entry *ftid_tab;	/* Normal filters */
	union aopen_entry *atid_tab;
	struct rte_bitmap *ftid_bmap;
	uint8_t *ftid_bmap_array;
	unsigned int nftids, natids;
	unsigned int ftid_base, hash_base;

	union aopen_entry *afree;
	unsigned int atids_in_use;

	/* TIDs in the TCAM */
	rte_atomic32_t tids_in_use;
	/* TIDs in the HASH */
	rte_atomic32_t hash_tids_in_use;
	rte_atomic32_t conns_in_use;

	rte_spinlock_t atid_lock __rte_cache_aligned;
	rte_spinlock_t ftid_lock;
};

static inline void *lookup_tid(const struct tid_info *t, unsigned int tid)
{
	return tid < t->ntids ? t->tid_tab[tid] : NULL;
}

static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)
{
	return atid < t->natids ? t->atid_tab[atid].data : NULL;
}

int cxgbe_alloc_atid(struct tid_info *t, void *data);
void cxgbe_free_atid(struct tid_info *t, unsigned int atid);
void cxgbe_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid,
		      unsigned short family);
void cxgbe_insert_tid(struct tid_info *t, void *data, unsigned int tid,
		      unsigned short family);

#endif /* _CXGBE_OFLD_H_ */