2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __ECORE_L2_H__
32 #define __ECORE_L2_H__
37 #include "ecore_spq.h"
38 #include "ecore_l2_api.h"
40 #define MAX_QUEUES_PER_QZONE (sizeof(unsigned long) * 8)
41 #define ECORE_QUEUE_CID_PF (0xff)
43 /* Almost identical to the ecore_queue_start_common_params,
44 * but here we maintain the SB index in IGU CAM.
46 struct ecore_queue_cid_params {
52 /* Additional parameters required for initialization of the queue_cid
53 * and are relevant only for a PF initializing one for its VFs.
55 struct ecore_queue_cid_vf_params {
56 /* Should match the VF's relative index */
59 /* 0-based queue index. Should reflect the relative qzone the
60 * VF thinks is associated with it [in its range].
64 /* Indicates a VF is legacy, making it differ in several things:
65 * - Producers would be placed in a different place.
66 * - Makes assumptions regarding the CIDs.
70 /* For VFs, this index arrives via TLV to diffrentiate between
71 * different queues opened on the same qzone, and is passed
72 * [where the PF would have allocated it internally for its own].
77 struct ecore_queue_cid {
78 /* For stats-id, the `rel' is actually absolute as well */
79 struct ecore_queue_cid_params rel;
80 struct ecore_queue_cid_params abs;
82 /* These have no 'relative' meaning */
91 /* VFs queues are mapped differently, so we need to know the
92 * relative queue associated with them [0-based].
93 * Notice this is relevant on the *PF* queue-cid of its VF's queues,
94 * and not on the VF itself.
99 /* We need an additional index to diffrentiate between queues opened
100 * for same queue-zone, as VFs would have to communicate the info
101 * to the PF [otherwise PF has no way to diffrentiate].
105 /* Legacy VFs might have Rx producer located elsewhere */
107 #define ECORE_QCID_LEGACY_VF_RX_PROD (1 << 0)
108 #define ECORE_QCID_LEGACY_VF_CID (1 << 1)
110 struct ecore_hwfn *p_owner;
113 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn);
114 void ecore_l2_setup(struct ecore_hwfn *p_hwfn);
115 void ecore_l2_free(struct ecore_hwfn *p_hwfn);
117 void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn,
118 struct ecore_queue_cid *p_cid);
120 struct ecore_queue_cid *
121 ecore_eth_queue_to_cid(struct ecore_hwfn *p_hwfn, u16 opaque_fid,
122 struct ecore_queue_start_common_params *p_params,
124 struct ecore_queue_cid_vf_params *p_vf_params);
127 ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn,
128 struct ecore_sp_vport_start_params *p_params);
131 * @brief - Starts an Rx queue, when queue_cid is already prepared
135 * @param bd_max_bytes
136 * @param bd_chain_phys_addr
137 * @param cqe_pbl_addr
138 * @param cqe_pbl_size
140 * @return enum _ecore_status_t
143 ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn,
144 struct ecore_queue_cid *p_cid,
146 dma_addr_t bd_chain_phys_addr,
147 dma_addr_t cqe_pbl_addr,
151 * @brief - Starts a Tx queue, where queue_cid is already prepared
157 * @param p_pq_params - parameters for choosing the PQ for this Tx queue
159 * @return enum _ecore_status_t
162 ecore_eth_txq_start_ramrod(struct ecore_hwfn *p_hwfn,
163 struct ecore_queue_cid *p_cid,
164 dma_addr_t pbl_addr, u16 pbl_size,
167 u8 ecore_mcast_bin_from_mac(u8 *mac);
169 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn,
170 struct ecore_ptt *p_ptt,
172 struct ecore_queue_cid *p_cid);
174 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn,
175 struct ecore_ptt *p_ptt,
177 struct ecore_queue_cid *p_cid);
179 enum _ecore_status_t ecore_get_rxq_coalesce(struct ecore_hwfn *p_hwfn,
180 struct ecore_ptt *p_ptt,
181 struct ecore_queue_cid *p_cid,
184 enum _ecore_status_t ecore_get_txq_coalesce(struct ecore_hwfn *p_hwfn,
185 struct ecore_ptt *p_ptt,
186 struct ecore_queue_cid *p_cid,