summaryrefslogtreecommitdiffstats
path: root/sys/dev/qlnx/qlnxe/ecore_ll2.h
blob: 4b92c816bb3db8de3cd8578a9ae2e016a2eb7456 (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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 * Copyright (c) 2017-2018 Cavium, Inc. 
 * All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD$
 *
 */

#ifndef __ECORE_LL2_H__
#define __ECORE_LL2_H__

#include "ecore.h"
#include "ecore_hsi_eth.h"
#include "ecore_chain.h"
#include "ecore_hsi_common.h"
#include "ecore_ll2_api.h"
#include "ecore_sp_api.h"

/* ECORE LL2: internal structures and functions*/
#define ECORE_MAX_NUM_OF_LL2_CONNECTIONS                    (4)

static OSAL_INLINE u8 ecore_ll2_handle_to_queue_id(struct ecore_hwfn *p_hwfn,
					      u8 handle)
{
	return p_hwfn->hw_info.resc_start[ECORE_LL2_QUEUE] + handle;
}

struct ecore_ll2_rx_packet
{
	osal_list_entry_t   list_entry;
	struct core_rx_bd_with_buff_len   *rxq_bd;
	dma_addr_t          rx_buf_addr;
	u16                 buf_length;
	void                *cookie;
	u8                  placement_offset;
	u16                 parse_flags;
	u16                 packet_length;
	u16                 vlan;
	u32                 opaque_data[2];
};

struct ecore_ll2_tx_packet
{
	osal_list_entry_t       list_entry;
	u16                     bd_used;
	bool                    notify_fw;
	void                    *cookie;
	struct {
		struct core_tx_bd       *txq_bd;
		dma_addr_t              tx_frag;
		u16                     frag_len;
	}   bds_set[1];
	/* Flexible Array of bds_set determined by max_bds_per_packet */
};

struct ecore_ll2_rx_queue {
	osal_spinlock_t		lock;
	struct ecore_chain	rxq_chain;
	struct ecore_chain	rcq_chain;
	u8			rx_sb_index;
	bool			b_cb_registred;
	__le16			*p_fw_cons;
	osal_list_t		active_descq;
	osal_list_t		free_descq;
	osal_list_t		posting_descq;
	struct ecore_ll2_rx_packet	*descq_array;
	void OSAL_IOMEM		*set_prod_addr;
};

struct ecore_ll2_tx_queue {
	osal_spinlock_t			lock;
	struct ecore_chain		txq_chain;
	u8				tx_sb_index;
	bool				b_cb_registred;
	__le16				*p_fw_cons;
	osal_list_t			active_descq;
	osal_list_t			free_descq;
	osal_list_t			sending_descq;
	struct ecore_ll2_tx_packet	*descq_array;
	struct ecore_ll2_tx_packet	*cur_send_packet;
	struct ecore_ll2_tx_packet	cur_completing_packet;
	u16				cur_completing_bd_idx;
	void OSAL_IOMEM			*doorbell_addr;
	u16				bds_idx;
	u16				cur_send_frag_num;
	u16				cur_completing_frag_num;
	bool				b_completing_packet;
};

struct ecore_ll2_info {
	osal_mutex_t			mutex;

	struct ecore_ll2_acquire_data_inputs input;
	u32				cid;
	u8				my_id;
	u8				queue_id;
	u8				tx_stats_id;
	bool				b_active;
	enum core_tx_dest		tx_dest;
	u8				tx_stats_en;
	u8				main_func_queue;
	struct ecore_ll2_rx_queue	rx_queue;
	struct ecore_ll2_tx_queue	tx_queue;
	struct ecore_ll2_cbs		cbs;
};

/**
* @brief ecore_ll2_alloc - Allocates LL2 connections set
*
* @param p_hwfn
*
* @return enum _ecore_status_t
*/
enum _ecore_status_t ecore_ll2_alloc(struct ecore_hwfn *p_hwfn);

/**
* @brief ecore_ll2_setup - Inits LL2 connections set
*
* @param p_hwfn
*
*/
void ecore_ll2_setup(struct ecore_hwfn *p_hwfn);

/**
* @brief ecore_ll2_free - Releases LL2 connections set
*
* @param p_hwfn
*
*/
void ecore_ll2_free(struct ecore_hwfn *p_hwfn);

/**
 * @brief ecore_ll2_get_fragment_of_tx_packet
 *
 * @param p_hwfn
 * @param connection_handle    LL2 connection's handle
 *                              obtained from
 *                              ecore_ll2_require_connection
 * @param addr
 * @param last_fragment)
 *
 * @return enum _ecore_status_t
 */
enum _ecore_status_t
ecore_ll2_get_fragment_of_tx_packet(struct ecore_hwfn *p_hwfn,
				    u8 connection_handle,
				    dma_addr_t *addr,
				    bool *last_fragment);

#endif /*__ECORE_LL2_H__*/
OpenPOWER on IntegriCloud