xref: /linux/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h (revision 1a91649fd35ff53a646981e212496f1ae92a8487)
1f7917c00SJeff Kirsher /*
2f7917c00SJeff Kirsher  * This file is part of the Chelsio T4 Ethernet driver for Linux.
3f7917c00SJeff Kirsher  *
4578b46b9SRahul Lakkireddy  * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved.
5f7917c00SJeff Kirsher  *
6f7917c00SJeff Kirsher  * This software is available to you under a choice of one of two
7f7917c00SJeff Kirsher  * licenses.  You may choose to be licensed under the terms of the GNU
8f7917c00SJeff Kirsher  * General Public License (GPL) Version 2, available from the file
9f7917c00SJeff Kirsher  * COPYING in the main directory of this source tree, or the
10f7917c00SJeff Kirsher  * OpenIB.org BSD license below:
11f7917c00SJeff Kirsher  *
12f7917c00SJeff Kirsher  *     Redistribution and use in source and binary forms, with or
13f7917c00SJeff Kirsher  *     without modification, are permitted provided that the following
14f7917c00SJeff Kirsher  *     conditions are met:
15f7917c00SJeff Kirsher  *
16f7917c00SJeff Kirsher  *      - Redistributions of source code must retain the above
17f7917c00SJeff Kirsher  *        copyright notice, this list of conditions and the following
18f7917c00SJeff Kirsher  *        disclaimer.
19f7917c00SJeff Kirsher  *
20f7917c00SJeff Kirsher  *      - Redistributions in binary form must reproduce the above
21f7917c00SJeff Kirsher  *        copyright notice, this list of conditions and the following
22f7917c00SJeff Kirsher  *        disclaimer in the documentation and/or other materials
23f7917c00SJeff Kirsher  *        provided with the distribution.
24f7917c00SJeff Kirsher  *
25f7917c00SJeff Kirsher  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26f7917c00SJeff Kirsher  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27f7917c00SJeff Kirsher  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28f7917c00SJeff Kirsher  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29f7917c00SJeff Kirsher  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30f7917c00SJeff Kirsher  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31f7917c00SJeff Kirsher  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32f7917c00SJeff Kirsher  * SOFTWARE.
33f7917c00SJeff Kirsher  */
34f7917c00SJeff Kirsher 
3594cdb8bbSHariprasad Shenai #ifndef __CXGB4_ULD_H
3694cdb8bbSHariprasad Shenai #define __CXGB4_ULD_H
37f7917c00SJeff Kirsher 
38f7917c00SJeff Kirsher #include <linux/cache.h>
39f7917c00SJeff Kirsher #include <linux/spinlock.h>
40f7917c00SJeff Kirsher #include <linux/skbuff.h>
41793dad94SVipul Pandya #include <linux/inetdevice.h>
42f7917c00SJeff Kirsher #include <linux/atomic.h>
4327999805SHariprasad S #include "cxgb4.h"
44f7917c00SJeff Kirsher 
450fbc81b3SHariprasad Shenai #define MAX_ULD_QSETS 16
460fbc81b3SHariprasad Shenai 
47f7917c00SJeff Kirsher /* CPL message priority levels */
48f7917c00SJeff Kirsher enum {
49f7917c00SJeff Kirsher 	CPL_PRIORITY_DATA     = 0,  /* data messages */
50f7917c00SJeff Kirsher 	CPL_PRIORITY_SETUP    = 1,  /* connection setup messages */
51f7917c00SJeff Kirsher 	CPL_PRIORITY_TEARDOWN = 0,  /* connection teardown messages */
52f7917c00SJeff Kirsher 	CPL_PRIORITY_LISTEN   = 1,  /* listen start/stop messages */
53f7917c00SJeff Kirsher 	CPL_PRIORITY_ACK      = 1,  /* RX ACK messages */
54f7917c00SJeff Kirsher 	CPL_PRIORITY_CONTROL  = 1   /* control messages */
55f7917c00SJeff Kirsher };
56f7917c00SJeff Kirsher 
57f7917c00SJeff Kirsher #define INIT_TP_WR(w, tid) do { \
58e2ac9628SHariprasad Shenai 	(w)->wr.wr_hi = htonl(FW_WR_OP_V(FW_TP_WR) | \
59e2ac9628SHariprasad Shenai 			      FW_WR_IMMDLEN_V(sizeof(*w) - sizeof(w->wr))); \
60e2ac9628SHariprasad Shenai 	(w)->wr.wr_mid = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*w), 16)) | \
61e2ac9628SHariprasad Shenai 			       FW_WR_FLOWID_V(tid)); \
62f7917c00SJeff Kirsher 	(w)->wr.wr_lo = cpu_to_be64(0); \
63f7917c00SJeff Kirsher } while (0)
64f7917c00SJeff Kirsher 
65f7917c00SJeff Kirsher #define INIT_TP_WR_CPL(w, cpl, tid) do { \
66f7917c00SJeff Kirsher 	INIT_TP_WR(w, tid); \
67f7917c00SJeff Kirsher 	OPCODE_TID(w) = htonl(MK_OPCODE_TID(cpl, tid)); \
68f7917c00SJeff Kirsher } while (0)
69f7917c00SJeff Kirsher 
70f7917c00SJeff Kirsher #define INIT_ULPTX_WR(w, wrlen, atomic, tid) do { \
71e2ac9628SHariprasad Shenai 	(w)->wr.wr_hi = htonl(FW_WR_OP_V(FW_ULPTX_WR) | \
72e2ac9628SHariprasad Shenai 			      FW_WR_ATOMIC_V(atomic)); \
73e2ac9628SHariprasad Shenai 	(w)->wr.wr_mid = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(wrlen, 16)) | \
74e2ac9628SHariprasad Shenai 			       FW_WR_FLOWID_V(tid)); \
75f7917c00SJeff Kirsher 	(w)->wr.wr_lo = cpu_to_be64(0); \
76f7917c00SJeff Kirsher } while (0)
77f7917c00SJeff Kirsher 
78f7917c00SJeff Kirsher /* Special asynchronous notification message */
79f7917c00SJeff Kirsher #define CXGB4_MSG_AN ((void *)1)
80ab677ff4SHariprasad Shenai #define TX_ULD(uld)(((uld) != CXGB4_ULD_CRYPTO) ? CXGB4_TX_OFLD :\
81ab677ff4SHariprasad Shenai 		      CXGB4_TX_CRYPTO)
82f7917c00SJeff Kirsher 
83f7917c00SJeff Kirsher struct serv_entry {
84f7917c00SJeff Kirsher 	void *data;
85f7917c00SJeff Kirsher };
86f7917c00SJeff Kirsher 
87f7917c00SJeff Kirsher union aopen_entry {
88f7917c00SJeff Kirsher 	void *data;
89f7917c00SJeff Kirsher 	union aopen_entry *next;
90f7917c00SJeff Kirsher };
91f7917c00SJeff Kirsher 
92f7917c00SJeff Kirsher /*
93f7917c00SJeff Kirsher  * Holds the size, base address, free list start, etc of the TID, server TID,
94f7917c00SJeff Kirsher  * and active-open TID tables.  The tables themselves are allocated dynamically.
95f7917c00SJeff Kirsher  */
96f7917c00SJeff Kirsher struct tid_info {
97f7917c00SJeff Kirsher 	void **tid_tab;
98f7917c00SJeff Kirsher 	unsigned int ntids;
99f7917c00SJeff Kirsher 
100f7917c00SJeff Kirsher 	struct serv_entry *stid_tab;
101f7917c00SJeff Kirsher 	unsigned long *stid_bmap;
102f7917c00SJeff Kirsher 	unsigned int nstids;
103f7917c00SJeff Kirsher 	unsigned int stid_base;
1049a1bb9f6SHariprasad Shenai 	unsigned int hash_base;
105f7917c00SJeff Kirsher 
106f7917c00SJeff Kirsher 	union aopen_entry *atid_tab;
107f7917c00SJeff Kirsher 	unsigned int natids;
108f2b7e78dSVipul Pandya 	unsigned int atid_base;
109f7917c00SJeff Kirsher 
110f2b7e78dSVipul Pandya 	struct filter_entry *ftid_tab;
111578b46b9SRahul Lakkireddy 	unsigned long *ftid_bmap;
112f7917c00SJeff Kirsher 	unsigned int nftids;
113f7917c00SJeff Kirsher 	unsigned int ftid_base;
114636f9d37SVipul Pandya 	unsigned int aftid_base;
115636f9d37SVipul Pandya 	unsigned int aftid_end;
1169a4da2cdSVipul Pandya 	/* Server filter region */
1179a4da2cdSVipul Pandya 	unsigned int sftid_base;
1189a4da2cdSVipul Pandya 	unsigned int nsftids;
119f7917c00SJeff Kirsher 
120f7917c00SJeff Kirsher 	spinlock_t atid_lock ____cacheline_aligned_in_smp;
121f7917c00SJeff Kirsher 	union aopen_entry *afree;
122f7917c00SJeff Kirsher 	unsigned int atids_in_use;
123f7917c00SJeff Kirsher 
124f7917c00SJeff Kirsher 	spinlock_t stid_lock;
125f7917c00SJeff Kirsher 	unsigned int stids_in_use;
1261dec4cecSGanesh Goudar 	unsigned int v6_stids_in_use;
1272248b293SHariprasad Shenai 	unsigned int sftids_in_use;
128f7917c00SJeff Kirsher 
1299a1bb9f6SHariprasad Shenai 	/* TIDs in the TCAM */
130f7917c00SJeff Kirsher 	atomic_t tids_in_use;
1319a1bb9f6SHariprasad Shenai 	/* TIDs in the HASH */
1329a1bb9f6SHariprasad Shenai 	atomic_t hash_tids_in_use;
1331dec4cecSGanesh Goudar 	atomic_t conns_in_use;
134578b46b9SRahul Lakkireddy 	/* lock for setting/clearing filter bitmap */
135578b46b9SRahul Lakkireddy 	spinlock_t ftid_lock;
136f7917c00SJeff Kirsher };
137f7917c00SJeff Kirsher 
138f7917c00SJeff Kirsher static inline void *lookup_tid(const struct tid_info *t, unsigned int tid)
139f7917c00SJeff Kirsher {
140f7917c00SJeff Kirsher 	return tid < t->ntids ? t->tid_tab[tid] : NULL;
141f7917c00SJeff Kirsher }
142f7917c00SJeff Kirsher 
143f7917c00SJeff Kirsher static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)
144f7917c00SJeff Kirsher {
145f7917c00SJeff Kirsher 	return atid < t->natids ? t->atid_tab[atid].data : NULL;
146f7917c00SJeff Kirsher }
147f7917c00SJeff Kirsher 
148f7917c00SJeff Kirsher static inline void *lookup_stid(const struct tid_info *t, unsigned int stid)
149f7917c00SJeff Kirsher {
150470c60c4SKumar Sanghvi 	/* Is it a server filter TID? */
151470c60c4SKumar Sanghvi 	if (t->nsftids && (stid >= t->sftid_base)) {
152470c60c4SKumar Sanghvi 		stid -= t->sftid_base;
153470c60c4SKumar Sanghvi 		stid += t->nstids;
154470c60c4SKumar Sanghvi 	} else {
155f7917c00SJeff Kirsher 		stid -= t->stid_base;
156470c60c4SKumar Sanghvi 	}
157470c60c4SKumar Sanghvi 
158dca4faebSVipul Pandya 	return stid < (t->nstids + t->nsftids) ? t->stid_tab[stid].data : NULL;
159f7917c00SJeff Kirsher }
160f7917c00SJeff Kirsher 
161f7917c00SJeff Kirsher static inline void cxgb4_insert_tid(struct tid_info *t, void *data,
1621dec4cecSGanesh Goudar 				    unsigned int tid, unsigned short family)
163f7917c00SJeff Kirsher {
164f7917c00SJeff Kirsher 	t->tid_tab[tid] = data;
1651dec4cecSGanesh Goudar 	if (t->hash_base && (tid >= t->hash_base)) {
1661dec4cecSGanesh Goudar 		if (family == AF_INET6)
1671dec4cecSGanesh Goudar 			atomic_add(2, &t->hash_tids_in_use);
1681dec4cecSGanesh Goudar 		else
1699a1bb9f6SHariprasad Shenai 			atomic_inc(&t->hash_tids_in_use);
1701dec4cecSGanesh Goudar 	} else {
1711dec4cecSGanesh Goudar 		if (family == AF_INET6)
1721dec4cecSGanesh Goudar 			atomic_add(2, &t->tids_in_use);
1739a1bb9f6SHariprasad Shenai 		else
174f7917c00SJeff Kirsher 			atomic_inc(&t->tids_in_use);
175f7917c00SJeff Kirsher 	}
1761dec4cecSGanesh Goudar 	atomic_inc(&t->conns_in_use);
1771dec4cecSGanesh Goudar }
178f7917c00SJeff Kirsher 
179f7917c00SJeff Kirsher int cxgb4_alloc_atid(struct tid_info *t, void *data);
180f7917c00SJeff Kirsher int cxgb4_alloc_stid(struct tid_info *t, int family, void *data);
181dca4faebSVipul Pandya int cxgb4_alloc_sftid(struct tid_info *t, int family, void *data);
182f7917c00SJeff Kirsher void cxgb4_free_atid(struct tid_info *t, unsigned int atid);
183f7917c00SJeff Kirsher void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family);
1841dec4cecSGanesh Goudar void cxgb4_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid,
1851dec4cecSGanesh Goudar 		      unsigned short family);
186f7917c00SJeff Kirsher struct in6_addr;
187f7917c00SJeff Kirsher 
188f7917c00SJeff Kirsher int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
189793dad94SVipul Pandya 			__be32 sip, __be16 sport, __be16 vlan,
190793dad94SVipul Pandya 			unsigned int queue);
19180f40c1fSVipul Pandya int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
19280f40c1fSVipul Pandya 			 const struct in6_addr *sip, __be16 sport,
19380f40c1fSVipul Pandya 			 unsigned int queue);
19480f40c1fSVipul Pandya int cxgb4_remove_server(const struct net_device *dev, unsigned int stid,
19580f40c1fSVipul Pandya 			unsigned int queue, bool ipv6);
196dca4faebSVipul Pandya int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid,
197793dad94SVipul Pandya 			       __be32 sip, __be16 sport, __be16 vlan,
198793dad94SVipul Pandya 			       unsigned int queue,
199793dad94SVipul Pandya 			       unsigned char port, unsigned char mask);
200dca4faebSVipul Pandya int cxgb4_remove_server_filter(const struct net_device *dev, unsigned int stid,
201dca4faebSVipul Pandya 			       unsigned int queue, bool ipv6);
202a3e3b285SAnish Bhatt 
203578b46b9SRahul Lakkireddy /* Filter operation context to allow callers of cxgb4_set_filter() and
204578b46b9SRahul Lakkireddy  * cxgb4_del_filter() to wait for an asynchronous completion.
205578b46b9SRahul Lakkireddy  */
206578b46b9SRahul Lakkireddy struct filter_ctx {
207578b46b9SRahul Lakkireddy 	struct completion completion;	/* completion rendezvous */
208578b46b9SRahul Lakkireddy 	void *closure;			/* caller's opaque information */
209578b46b9SRahul Lakkireddy 	int result;			/* result of operation */
210578b46b9SRahul Lakkireddy 	u32 tid;			/* to store tid */
211578b46b9SRahul Lakkireddy };
212578b46b9SRahul Lakkireddy 
213578b46b9SRahul Lakkireddy struct ch_filter_specification;
214578b46b9SRahul Lakkireddy 
21562488e4bSKumar Sanghvi int cxgb4_get_free_ftid(struct net_device *dev, int family);
216578b46b9SRahul Lakkireddy int __cxgb4_set_filter(struct net_device *dev, int filter_id,
217578b46b9SRahul Lakkireddy 		       struct ch_filter_specification *fs,
218578b46b9SRahul Lakkireddy 		       struct filter_ctx *ctx);
219578b46b9SRahul Lakkireddy int __cxgb4_del_filter(struct net_device *dev, int filter_id,
2203b0b3beeSKumar Sanghvi 		       struct ch_filter_specification *fs,
221578b46b9SRahul Lakkireddy 		       struct filter_ctx *ctx);
222578b46b9SRahul Lakkireddy int cxgb4_set_filter(struct net_device *dev, int filter_id,
223578b46b9SRahul Lakkireddy 		     struct ch_filter_specification *fs);
2243b0b3beeSKumar Sanghvi int cxgb4_del_filter(struct net_device *dev, int filter_id,
2253b0b3beeSKumar Sanghvi 		     struct ch_filter_specification *fs);
226e0f911c8SKumar Sanghvi int cxgb4_get_filter_counters(struct net_device *dev, unsigned int fidx,
2279d922d4bSKumar Sanghvi 			      u64 *hitcnt, u64 *bytecnt, bool hash);
228578b46b9SRahul Lakkireddy 
229f7917c00SJeff Kirsher static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue)
230f7917c00SJeff Kirsher {
231f7917c00SJeff Kirsher 	skb_set_queue_mapping(skb, (queue << 1) | prio);
232f7917c00SJeff Kirsher }
233f7917c00SJeff Kirsher 
234f7917c00SJeff Kirsher enum cxgb4_uld {
2350fbc81b3SHariprasad Shenai 	CXGB4_ULD_INIT,
236f7917c00SJeff Kirsher 	CXGB4_ULD_RDMA,
237f7917c00SJeff Kirsher 	CXGB4_ULD_ISCSI,
2382fddfb81SVarun Prakash 	CXGB4_ULD_ISCSIT,
2390fbc81b3SHariprasad Shenai 	CXGB4_ULD_CRYPTO,
240f7917c00SJeff Kirsher 	CXGB4_ULD_MAX
241f7917c00SJeff Kirsher };
242f7917c00SJeff Kirsher 
243ab677ff4SHariprasad Shenai enum cxgb4_tx_uld {
244ab677ff4SHariprasad Shenai 	CXGB4_TX_OFLD,
245ab677ff4SHariprasad Shenai 	CXGB4_TX_CRYPTO,
246ab677ff4SHariprasad Shenai 	CXGB4_TX_MAX
247ab677ff4SHariprasad Shenai };
248ab677ff4SHariprasad Shenai 
249ab677ff4SHariprasad Shenai enum cxgb4_txq_type {
250ab677ff4SHariprasad Shenai 	CXGB4_TXQ_ETH,
251ab677ff4SHariprasad Shenai 	CXGB4_TXQ_ULD,
252ab677ff4SHariprasad Shenai 	CXGB4_TXQ_CTRL,
253ab677ff4SHariprasad Shenai 	CXGB4_TXQ_MAX
254ab677ff4SHariprasad Shenai };
255ab677ff4SHariprasad Shenai 
256f7917c00SJeff Kirsher enum cxgb4_state {
257f7917c00SJeff Kirsher 	CXGB4_STATE_UP,
258f7917c00SJeff Kirsher 	CXGB4_STATE_START_RECOVERY,
259f7917c00SJeff Kirsher 	CXGB4_STATE_DOWN,
260f7917c00SJeff Kirsher 	CXGB4_STATE_DETACH
261f7917c00SJeff Kirsher };
262f7917c00SJeff Kirsher 
263881806bcSVipul Pandya enum cxgb4_control {
264881806bcSVipul Pandya 	CXGB4_CONTROL_DB_FULL,
265881806bcSVipul Pandya 	CXGB4_CONTROL_DB_EMPTY,
266881806bcSVipul Pandya 	CXGB4_CONTROL_DB_DROP,
267881806bcSVipul Pandya };
268881806bcSVipul Pandya 
269f7917c00SJeff Kirsher struct pci_dev;
270f7917c00SJeff Kirsher struct l2t_data;
271f7917c00SJeff Kirsher struct net_device;
272f7917c00SJeff Kirsher struct pkt_gl;
273f7917c00SJeff Kirsher struct tp_tcp_stats;
2742337ba42SVarun Prakash struct t4_lro_mgr;
275f7917c00SJeff Kirsher 
276f7917c00SJeff Kirsher struct cxgb4_range {
277f7917c00SJeff Kirsher 	unsigned int start;
278f7917c00SJeff Kirsher 	unsigned int size;
279f7917c00SJeff Kirsher };
280f7917c00SJeff Kirsher 
281f7917c00SJeff Kirsher struct cxgb4_virt_res {                      /* virtualized HW resources */
282f7917c00SJeff Kirsher 	struct cxgb4_range ddp;
283f7917c00SJeff Kirsher 	struct cxgb4_range iscsi;
284f7917c00SJeff Kirsher 	struct cxgb4_range stag;
285f7917c00SJeff Kirsher 	struct cxgb4_range rq;
286f7917c00SJeff Kirsher 	struct cxgb4_range pbl;
287f7917c00SJeff Kirsher 	struct cxgb4_range qp;
288f7917c00SJeff Kirsher 	struct cxgb4_range cq;
289f7917c00SJeff Kirsher 	struct cxgb4_range ocq;
29072a56ca9SHarsh Jain 	unsigned int ncrypto_fc;
291f7917c00SJeff Kirsher };
292f7917c00SJeff Kirsher 
293ee0863baSHarsh Jain struct chcr_stats_debug {
294ee0863baSHarsh Jain 	atomic_t cipher_rqst;
295ee0863baSHarsh Jain 	atomic_t digest_rqst;
296ee0863baSHarsh Jain 	atomic_t aead_rqst;
297ee0863baSHarsh Jain 	atomic_t complete;
298ee0863baSHarsh Jain 	atomic_t error;
299ee0863baSHarsh Jain 	atomic_t fallback;
300a6ec572bSAtul Gupta 	atomic_t ipsec_cnt;
301ee0863baSHarsh Jain };
302ee0863baSHarsh Jain 
303f7917c00SJeff Kirsher #define OCQ_WIN_OFFSET(pdev, vres) \
304f7917c00SJeff Kirsher 	(pci_resource_len((pdev), 2) - roundup_pow_of_two((vres)->ocq.size))
305f7917c00SJeff Kirsher 
306f7917c00SJeff Kirsher /*
307f7917c00SJeff Kirsher  * Block of information the LLD provides to ULDs attaching to a device.
308f7917c00SJeff Kirsher  */
309f7917c00SJeff Kirsher struct cxgb4_lld_info {
310f7917c00SJeff Kirsher 	struct pci_dev *pdev;                /* associated PCI device */
311f7917c00SJeff Kirsher 	struct l2t_data *l2t;                /* L2 table */
312f7917c00SJeff Kirsher 	struct tid_info *tids;               /* TID table */
313f7917c00SJeff Kirsher 	struct net_device **ports;           /* device ports */
314f7917c00SJeff Kirsher 	const struct cxgb4_virt_res *vr;     /* assorted HW resources */
315f7917c00SJeff Kirsher 	const unsigned short *mtus;          /* MTU table */
316f7917c00SJeff Kirsher 	const unsigned short *rxq_ids;       /* the ULD's Rx queue ids */
317cf38be6dSHariprasad Shenai 	const unsigned short *ciq_ids;       /* the ULD's concentrator IQ ids */
318f7917c00SJeff Kirsher 	unsigned short nrxq;                 /* # of Rx queues */
319f7917c00SJeff Kirsher 	unsigned short ntxq;                 /* # of Tx queues */
320cf38be6dSHariprasad Shenai 	unsigned short nciq;		     /* # of concentrator IQ */
321f7917c00SJeff Kirsher 	unsigned char nchan:4;               /* # of channels */
322f7917c00SJeff Kirsher 	unsigned char nports:4;              /* # of ports */
323f7917c00SJeff Kirsher 	unsigned char wr_cred;               /* WR 16-byte credits */
324f7917c00SJeff Kirsher 	unsigned char adapter_type;          /* type of adapter */
325f7917c00SJeff Kirsher 	unsigned char fw_api_ver;            /* FW API version */
326a6ec572bSAtul Gupta 	unsigned char crypto;                /* crypto support */
327f7917c00SJeff Kirsher 	unsigned int fw_vers;                /* FW version */
328f7917c00SJeff Kirsher 	unsigned int iscsi_iolen;            /* iSCSI max I/O length */
3297730b4c7SHariprasad Shenai 	unsigned int cclk_ps;                /* Core clock period in psec */
330f7917c00SJeff Kirsher 	unsigned short udb_density;          /* # of user DB/page */
331f7917c00SJeff Kirsher 	unsigned short ucq_density;          /* # of user CQs/page */
332dca4faebSVipul Pandya 	unsigned short filt_mode;            /* filter optional components */
333dca4faebSVipul Pandya 	unsigned short tx_modq[NCHAN];       /* maps each tx channel to a */
334dca4faebSVipul Pandya 					     /* scheduler queue */
335f7917c00SJeff Kirsher 	void __iomem *gts_reg;               /* address of GTS register */
336f7917c00SJeff Kirsher 	void __iomem *db_reg;                /* address of kernel doorbell */
3373069ee9bSVipul Pandya 	int dbfifo_int_thresh;		     /* doorbell fifo int threshold */
33804e10e21SHariprasad Shenai 	unsigned int sge_ingpadboundary;     /* SGE ingress padding boundary */
33904e10e21SHariprasad Shenai 	unsigned int sge_egrstatuspagesize;  /* SGE egress status page size */
340dca4faebSVipul Pandya 	unsigned int sge_pktshift;           /* Padding between CPL and */
341dca4faebSVipul Pandya 					     /*	packet data */
34235b1de55SHariprasad Shenai 	unsigned int pf;		     /* Physical Function we're using */
343dca4faebSVipul Pandya 	bool enable_fw_ofld_conn;            /* Enable connection through fw */
344dca4faebSVipul Pandya 					     /* WR */
3454c2c5763SHariprasad Shenai 	unsigned int max_ordird_qp;          /* Max ORD/IRD depth per RDMA QP */
3464c2c5763SHariprasad Shenai 	unsigned int max_ird_adapter;        /* Max IRD memory per adapter */
3471ac0f095SKumar Sanghvi 	bool ulptx_memwrite_dsgl;            /* use of T5 DSGL allowed */
3487714cb9eSVarun Prakash 	unsigned int iscsi_tagmask;	     /* iscsi ddp tag mask */
3497714cb9eSVarun Prakash 	unsigned int iscsi_pgsz_order;	     /* iscsi ddp page size orders */
3507714cb9eSVarun Prakash 	unsigned int iscsi_llimit;	     /* chip's iscsi region llimit */
35114c19b17SHarsh Jain 	unsigned int ulp_crypto;             /* crypto lookaside support */
3527714cb9eSVarun Prakash 	void **iscsi_ppm;		     /* iscsi page pod manager */
353982b81ebSHariprasad Shenai 	int nodeid;			     /* device numa node id */
354086de575SSteve Wise 	bool fr_nsmr_tpte_wr_support;	     /* FW supports FR_NSMR_TPTE_WR */
355f7917c00SJeff Kirsher };
356f7917c00SJeff Kirsher 
357f7917c00SJeff Kirsher struct cxgb4_uld_info {
358*1a91649fSArnd Bergmann 	char name[IFNAMSIZ];
35994cdb8bbSHariprasad Shenai 	void *handle;
36094cdb8bbSHariprasad Shenai 	unsigned int nrxq;
36194cdb8bbSHariprasad Shenai 	unsigned int rxq_size;
362ab677ff4SHariprasad Shenai 	unsigned int ntxq;
3630fbc81b3SHariprasad Shenai 	bool ciq;
3640fbc81b3SHariprasad Shenai 	bool lro;
36594cdb8bbSHariprasad Shenai 	void *(*add)(const struct cxgb4_lld_info *p);
36694cdb8bbSHariprasad Shenai 	int (*rx_handler)(void *handle, const __be64 *rsp,
36794cdb8bbSHariprasad Shenai 			  const struct pkt_gl *gl);
36894cdb8bbSHariprasad Shenai 	int (*state_change)(void *handle, enum cxgb4_state new_state);
36994cdb8bbSHariprasad Shenai 	int (*control)(void *handle, enum cxgb4_control control, ...);
37094cdb8bbSHariprasad Shenai 	int (*lro_rx_handler)(void *handle, const __be64 *rsp,
37194cdb8bbSHariprasad Shenai 			      const struct pkt_gl *gl,
37294cdb8bbSHariprasad Shenai 			      struct t4_lro_mgr *lro_mgr,
37394cdb8bbSHariprasad Shenai 			      struct napi_struct *napi);
37494cdb8bbSHariprasad Shenai 	void (*lro_flush)(struct t4_lro_mgr *);
375a6ec572bSAtul Gupta 	int (*tx_handler)(struct sk_buff *skb, struct net_device *dev);
37694cdb8bbSHariprasad Shenai };
37794cdb8bbSHariprasad Shenai 
378f7917c00SJeff Kirsher int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p);
379f7917c00SJeff Kirsher int cxgb4_unregister_uld(enum cxgb4_uld type);
380f7917c00SJeff Kirsher int cxgb4_ofld_send(struct net_device *dev, struct sk_buff *skb);
381ab677ff4SHariprasad Shenai int cxgb4_crypto_send(struct net_device *dev, struct sk_buff *skb);
382881806bcSVipul Pandya unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo);
383f7917c00SJeff Kirsher unsigned int cxgb4_port_chan(const struct net_device *dev);
384f7917c00SJeff Kirsher unsigned int cxgb4_port_viid(const struct net_device *dev);
38527999805SHariprasad S unsigned int cxgb4_tp_smt_idx(enum chip_type chip, unsigned int viid);
386f7917c00SJeff Kirsher unsigned int cxgb4_port_idx(const struct net_device *dev);
387f7917c00SJeff Kirsher unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
388f7917c00SJeff Kirsher 			    unsigned int *idx);
38992e7ae71SHariprasad Shenai unsigned int cxgb4_best_aligned_mtu(const unsigned short *mtus,
39092e7ae71SHariprasad Shenai 				    unsigned short header_size,
39192e7ae71SHariprasad Shenai 				    unsigned short data_size_max,
39292e7ae71SHariprasad Shenai 				    unsigned short data_size_align,
39392e7ae71SHariprasad Shenai 				    unsigned int *mtu_idxp);
394f7917c00SJeff Kirsher void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
395f7917c00SJeff Kirsher 			 struct tp_tcp_stats *v6);
396f7917c00SJeff Kirsher void cxgb4_iscsi_init(struct net_device *dev, unsigned int tag_mask,
397f7917c00SJeff Kirsher 		      const unsigned int *pgsz_order);
398f7917c00SJeff Kirsher struct sk_buff *cxgb4_pktgl_to_skb(const struct pkt_gl *gl,
399f7917c00SJeff Kirsher 				   unsigned int skb_len, unsigned int pull_len);
4003069ee9bSVipul Pandya int cxgb4_sync_txq_pidx(struct net_device *dev, u16 qid, u16 pidx, u16 size);
4013069ee9bSVipul Pandya int cxgb4_flush_eq_cache(struct net_device *dev);
402031cf476SHariprasad Shenai int cxgb4_read_tpte(struct net_device *dev, u32 stag, __be32 *tpte);
4037730b4c7SHariprasad Shenai u64 cxgb4_read_sge_timestamp(struct net_device *dev);
4043cbdb928SVipul Pandya 
405df64e4d3SHariprasad Shenai enum cxgb4_bar2_qtype { CXGB4_BAR2_QTYPE_EGRESS, CXGB4_BAR2_QTYPE_INGRESS };
406df64e4d3SHariprasad Shenai int cxgb4_bar2_sge_qregs(struct net_device *dev,
407df64e4d3SHariprasad Shenai 			 unsigned int qid,
408df64e4d3SHariprasad Shenai 			 enum cxgb4_bar2_qtype qtype,
40966cf188eSHariprasad S 			 int user,
410df64e4d3SHariprasad Shenai 			 u64 *pbar2_qoffset,
411df64e4d3SHariprasad Shenai 			 unsigned int *pbar2_qid);
412df64e4d3SHariprasad Shenai 
41394cdb8bbSHariprasad Shenai #endif  /* !__CXGB4_ULD_H */
414