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