1*14b24e2bSVaishali Kulkarni /*
2*14b24e2bSVaishali Kulkarni * CDDL HEADER START
3*14b24e2bSVaishali Kulkarni *
4*14b24e2bSVaishali Kulkarni * The contents of this file are subject to the terms of the
5*14b24e2bSVaishali Kulkarni * Common Development and Distribution License, v.1,  (the "License").
6*14b24e2bSVaishali Kulkarni * You may not use this file except in compliance with the License.
7*14b24e2bSVaishali Kulkarni *
8*14b24e2bSVaishali Kulkarni * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*14b24e2bSVaishali Kulkarni * or http://opensource.org/licenses/CDDL-1.0.
10*14b24e2bSVaishali Kulkarni * See the License for the specific language governing permissions
11*14b24e2bSVaishali Kulkarni * and limitations under the License.
12*14b24e2bSVaishali Kulkarni *
13*14b24e2bSVaishali Kulkarni * When distributing Covered Code, include this CDDL HEADER in each
14*14b24e2bSVaishali Kulkarni * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*14b24e2bSVaishali Kulkarni * If applicable, add the following below this CDDL HEADER, with the
16*14b24e2bSVaishali Kulkarni * fields enclosed by brackets "[]" replaced with your own identifying
17*14b24e2bSVaishali Kulkarni * information: Portions Copyright [yyyy] [name of copyright owner]
18*14b24e2bSVaishali Kulkarni *
19*14b24e2bSVaishali Kulkarni * CDDL HEADER END
20*14b24e2bSVaishali Kulkarni */
21*14b24e2bSVaishali Kulkarni 
22*14b24e2bSVaishali Kulkarni /*
23*14b24e2bSVaishali Kulkarni * Copyright 2014-2017 Cavium, Inc.
24*14b24e2bSVaishali Kulkarni * The contents of this file are subject to the terms of the Common Development
25*14b24e2bSVaishali Kulkarni * and Distribution License, v.1,  (the "License").
26*14b24e2bSVaishali Kulkarni 
27*14b24e2bSVaishali Kulkarni * You may not use this file except in compliance with the License.
28*14b24e2bSVaishali Kulkarni 
29*14b24e2bSVaishali Kulkarni * You can obtain a copy of the License at available
30*14b24e2bSVaishali Kulkarni * at http://opensource.org/licenses/CDDL-1.0
31*14b24e2bSVaishali Kulkarni 
32*14b24e2bSVaishali Kulkarni * See the License for the specific language governing permissions and
33*14b24e2bSVaishali Kulkarni * limitations under the License.
34*14b24e2bSVaishali Kulkarni */
35*14b24e2bSVaishali Kulkarni 
36*14b24e2bSVaishali Kulkarni #ifndef __ECORE_L2_H__
37*14b24e2bSVaishali Kulkarni #define __ECORE_L2_H__
38*14b24e2bSVaishali Kulkarni 
39*14b24e2bSVaishali Kulkarni 
40*14b24e2bSVaishali Kulkarni #include "ecore.h"
41*14b24e2bSVaishali Kulkarni #include "ecore_hw.h"
42*14b24e2bSVaishali Kulkarni #include "ecore_spq.h"
43*14b24e2bSVaishali Kulkarni #include "ecore_l2_api.h"
44*14b24e2bSVaishali Kulkarni 
45*14b24e2bSVaishali Kulkarni #define MAX_QUEUES_PER_QZONE	(sizeof(unsigned long) * 8)
46*14b24e2bSVaishali Kulkarni #define ECORE_QUEUE_CID_PF	(0xff)
47*14b24e2bSVaishali Kulkarni 
48*14b24e2bSVaishali Kulkarni /* Almost identical to the ecore_queue_start_common_params,
49*14b24e2bSVaishali Kulkarni  * but here we maintain the SB index in IGU CAM.
50*14b24e2bSVaishali Kulkarni  */
51*14b24e2bSVaishali Kulkarni struct ecore_queue_cid_params {
52*14b24e2bSVaishali Kulkarni 	u8 vport_id;
53*14b24e2bSVaishali Kulkarni 	u16 queue_id;
54*14b24e2bSVaishali Kulkarni 	u8 stats_id;
55*14b24e2bSVaishali Kulkarni };
56*14b24e2bSVaishali Kulkarni 
57*14b24e2bSVaishali Kulkarni  /* Additional parameters required for initialization of the queue_cid
58*14b24e2bSVaishali Kulkarni  * and are relevant only for a PF initializing one for its VFs.
59*14b24e2bSVaishali Kulkarni  */
60*14b24e2bSVaishali Kulkarni struct ecore_queue_cid_vf_params {
61*14b24e2bSVaishali Kulkarni 	/* Should match the VF's relative index */
62*14b24e2bSVaishali Kulkarni 	u8 vfid;
63*14b24e2bSVaishali Kulkarni 
64*14b24e2bSVaishali Kulkarni 	/* 0-based queue index. Should reflect the relative qzone the
65*14b24e2bSVaishali Kulkarni 	 * VF thinks is associated with it [in its range].
66*14b24e2bSVaishali Kulkarni 	 */
67*14b24e2bSVaishali Kulkarni 	u8 vf_qid;
68*14b24e2bSVaishali Kulkarni 
69*14b24e2bSVaishali Kulkarni 	/* Indicates a VF is legacy, making it differ in several things:
70*14b24e2bSVaishali Kulkarni 	 *  - Producers would be placed in a different place.
71*14b24e2bSVaishali Kulkarni 	 *  - Makes assumptions regarding the CIDs.
72*14b24e2bSVaishali Kulkarni 	 */
73*14b24e2bSVaishali Kulkarni 	u8 vf_legacy;
74*14b24e2bSVaishali Kulkarni 
75*14b24e2bSVaishali Kulkarni 	/* For VFs, this index arrives via TLV to diffrentiate between
76*14b24e2bSVaishali Kulkarni 	 * different queues opened on the same qzone, and is passed
77*14b24e2bSVaishali Kulkarni 	 * [where the PF would have allocated it internally for its own].
78*14b24e2bSVaishali Kulkarni 	 */
79*14b24e2bSVaishali Kulkarni 	u8 qid_usage_idx;
80*14b24e2bSVaishali Kulkarni };
81*14b24e2bSVaishali Kulkarni 
82*14b24e2bSVaishali Kulkarni struct ecore_queue_cid {
83*14b24e2bSVaishali Kulkarni 	/* For stats-id, the `rel' is actually absolute as well */
84*14b24e2bSVaishali Kulkarni 	struct ecore_queue_cid_params rel;
85*14b24e2bSVaishali Kulkarni 	struct ecore_queue_cid_params abs;
86*14b24e2bSVaishali Kulkarni 
87*14b24e2bSVaishali Kulkarni 	/* These have no 'relative' meaning */
88*14b24e2bSVaishali Kulkarni 	u16 sb_igu_id;
89*14b24e2bSVaishali Kulkarni 	u8 sb_idx;
90*14b24e2bSVaishali Kulkarni 
91*14b24e2bSVaishali Kulkarni 	u32 cid;
92*14b24e2bSVaishali Kulkarni 	u16 opaque_fid;
93*14b24e2bSVaishali Kulkarni 
94*14b24e2bSVaishali Kulkarni 	/* VFs queues are mapped differently, so we need to know the
95*14b24e2bSVaishali Kulkarni 	 * relative queue associated with them [0-based].
96*14b24e2bSVaishali Kulkarni 	 * Notice this is relevant on the *PF* queue-cid of its VF's queues,
97*14b24e2bSVaishali Kulkarni 	 * and not on the VF itself.
98*14b24e2bSVaishali Kulkarni 	 */
99*14b24e2bSVaishali Kulkarni 	u8 vfid;
100*14b24e2bSVaishali Kulkarni 	u8 vf_qid;
101*14b24e2bSVaishali Kulkarni 
102*14b24e2bSVaishali Kulkarni 	/* We need an additional index to diffrentiate between queues opened
103*14b24e2bSVaishali Kulkarni 	 * for same queue-zone, as VFs would have to communicate the info
104*14b24e2bSVaishali Kulkarni 	 * to the PF [otherwise PF has no way to diffrentiate].
105*14b24e2bSVaishali Kulkarni 	 */
106*14b24e2bSVaishali Kulkarni 	u8 qid_usage_idx;
107*14b24e2bSVaishali Kulkarni 
108*14b24e2bSVaishali Kulkarni 	/* Legacy VFs might have Rx producer located elsewhere */
109*14b24e2bSVaishali Kulkarni 	u8 vf_legacy;
110*14b24e2bSVaishali Kulkarni #define ECORE_QCID_LEGACY_VF_RX_PROD	(1 << 0)
111*14b24e2bSVaishali Kulkarni #define ECORE_QCID_LEGACY_VF_CID	(1 << 1)
112*14b24e2bSVaishali Kulkarni 
113*14b24e2bSVaishali Kulkarni 	struct ecore_hwfn *p_owner;
114*14b24e2bSVaishali Kulkarni };
115*14b24e2bSVaishali Kulkarni 
116*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn);
117*14b24e2bSVaishali Kulkarni void ecore_l2_setup(struct ecore_hwfn *p_hwfn);
118*14b24e2bSVaishali Kulkarni void ecore_l2_free(struct ecore_hwfn *p_hwfn);
119*14b24e2bSVaishali Kulkarni 
120*14b24e2bSVaishali Kulkarni void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn,
121*14b24e2bSVaishali Kulkarni 				 struct ecore_queue_cid *p_cid);
122*14b24e2bSVaishali Kulkarni 
123*14b24e2bSVaishali Kulkarni struct ecore_queue_cid *
124*14b24e2bSVaishali Kulkarni ecore_eth_queue_to_cid(struct ecore_hwfn *p_hwfn, u16 opaque_fid,
125*14b24e2bSVaishali Kulkarni 		       struct ecore_queue_start_common_params *p_params,
126*14b24e2bSVaishali Kulkarni 		       struct ecore_queue_cid_vf_params *p_vf_params);
127*14b24e2bSVaishali Kulkarni 
128*14b24e2bSVaishali Kulkarni enum _ecore_status_t
129*14b24e2bSVaishali Kulkarni ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn,
130*14b24e2bSVaishali Kulkarni 			 struct ecore_sp_vport_start_params *p_params);
131*14b24e2bSVaishali Kulkarni 
132*14b24e2bSVaishali Kulkarni /**
133*14b24e2bSVaishali Kulkarni  * @brief - Starts an Rx queue, when queue_cid is already prepared
134*14b24e2bSVaishali Kulkarni  *
135*14b24e2bSVaishali Kulkarni  * @param p_hwfn
136*14b24e2bSVaishali Kulkarni  * @param p_cid
137*14b24e2bSVaishali Kulkarni  * @param bd_max_bytes
138*14b24e2bSVaishali Kulkarni  * @param bd_chain_phys_addr
139*14b24e2bSVaishali Kulkarni  * @param cqe_pbl_addr
140*14b24e2bSVaishali Kulkarni  * @param cqe_pbl_size
141*14b24e2bSVaishali Kulkarni  *
142*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
143*14b24e2bSVaishali Kulkarni  */
144*14b24e2bSVaishali Kulkarni enum _ecore_status_t
145*14b24e2bSVaishali Kulkarni ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn,
146*14b24e2bSVaishali Kulkarni 			   struct ecore_queue_cid *p_cid,
147*14b24e2bSVaishali Kulkarni 			   u16 bd_max_bytes,
148*14b24e2bSVaishali Kulkarni 			   dma_addr_t bd_chain_phys_addr,
149*14b24e2bSVaishali Kulkarni 			   dma_addr_t cqe_pbl_addr,
150*14b24e2bSVaishali Kulkarni 			   u16 cqe_pbl_size);
151*14b24e2bSVaishali Kulkarni 
152*14b24e2bSVaishali Kulkarni /**
153*14b24e2bSVaishali Kulkarni  * @brief - Starts a Tx queue, where queue_cid is already prepared
154*14b24e2bSVaishali Kulkarni  *
155*14b24e2bSVaishali Kulkarni  * @param p_hwfn
156*14b24e2bSVaishali Kulkarni  * @param p_cid
157*14b24e2bSVaishali Kulkarni  * @param pbl_addr
158*14b24e2bSVaishali Kulkarni  * @param pbl_size
159*14b24e2bSVaishali Kulkarni  * @param p_pq_params - parameters for choosing the PQ for this Tx queue
160*14b24e2bSVaishali Kulkarni  *
161*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
162*14b24e2bSVaishali Kulkarni  */
163*14b24e2bSVaishali Kulkarni enum _ecore_status_t
164*14b24e2bSVaishali Kulkarni ecore_eth_txq_start_ramrod(struct ecore_hwfn *p_hwfn,
165*14b24e2bSVaishali Kulkarni 			   struct ecore_queue_cid *p_cid,
166*14b24e2bSVaishali Kulkarni 			   dma_addr_t pbl_addr, u16 pbl_size,
167*14b24e2bSVaishali Kulkarni 			   u16 pq_id);
168*14b24e2bSVaishali Kulkarni 
169*14b24e2bSVaishali Kulkarni u8 ecore_mcast_bin_from_mac(u8 *mac);
170*14b24e2bSVaishali Kulkarni 
171*14b24e2bSVaishali Kulkarni /**
172*14b24e2bSVaishali Kulkarni  * @brief - ecore_configure_rfs_ntuple_filter
173*14b24e2bSVaishali Kulkarni  *
174*14b24e2bSVaishali Kulkarni  * This ramrod should be used to add or remove arfs hw filter
175*14b24e2bSVaishali Kulkarni  *
176*14b24e2bSVaishali Kulkarni  * @params p_hwfn
177*14b24e2bSVaishali Kulkarni  * @params p_ptt
178*14b24e2bSVaishali Kulkarni  * @params p_cb		Used for ECORE_SPQ_MODE_CB,where client would initialize
179*14b24e2bSVaishali Kulkarni 			it with cookie and callback function address, if not
180*14b24e2bSVaishali Kulkarni 			using this mode then client must pass NULL.
181*14b24e2bSVaishali Kulkarni  * @params p_addr	p_addr is an actual packet header that needs to be
182*14b24e2bSVaishali Kulkarni  *			filter. It has to mapped with IO to read prior to
183*14b24e2bSVaishali Kulkarni  *			calling this, [contains 4 tuples- src ip, dest ip,
184*14b24e2bSVaishali Kulkarni  *			src port, dest port].
185*14b24e2bSVaishali Kulkarni  * @params length	length of p_addr header up to past the transport header.
186*14b24e2bSVaishali Kulkarni  * @params qid		receive packet will be directed to this queue.
187*14b24e2bSVaishali Kulkarni  * @params vport_id
188*14b24e2bSVaishali Kulkarni  * @params b_is_add	flag to add or remove filter.
189*14b24e2bSVaishali Kulkarni  *
190*14b24e2bSVaishali Kulkarni  */
191*14b24e2bSVaishali Kulkarni enum _ecore_status_t
192*14b24e2bSVaishali Kulkarni ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
193*14b24e2bSVaishali Kulkarni 				  struct ecore_ptt *p_ptt,
194*14b24e2bSVaishali Kulkarni 				  struct ecore_spq_comp_cb *p_cb,
195*14b24e2bSVaishali Kulkarni 				  dma_addr_t p_addr, u16 length,
196*14b24e2bSVaishali Kulkarni 				  u16 qid, u8 vport_id,
197*14b24e2bSVaishali Kulkarni 				  bool b_is_add);
198*14b24e2bSVaishali Kulkarni #endif