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.
32 #ifndef __ECORE_L2_H__
33 #define __ECORE_L2_H__
38 #include "ecore_spq.h"
39 #include "ecore_l2_api.h"
41 #define MAX_QUEUES_PER_QZONE (sizeof(unsigned long) * 8)
42 #define ECORE_QUEUE_CID_PF (0xff)
44 /* Almost identical to the ecore_queue_start_common_params,
45 * but here we maintain the SB index in IGU CAM.
47 struct ecore_queue_cid_params {
53 /* Additional parameters required for initialization of the queue_cid
54 * and are relevant only for a PF initializing one for its VFs.
56 struct ecore_queue_cid_vf_params {
57 /* Should match the VF's relative index */
60 /* 0-based queue index. Should reflect the relative qzone the
61 * VF thinks is associated with it [in its range].
65 /* Indicates a VF is legacy, making it differ in several things:
66 * - Producers would be placed in a different place.
67 * - Makes assumptions regarding the CIDs.
71 /* For VFs, this index arrives via TLV to diffrentiate between
72 * different queues opened on the same qzone, and is passed
73 * [where the PF would have allocated it internally for its own].
78 struct ecore_queue_cid {
79 /* For stats-id, the `rel' is actually absolute as well */
80 struct ecore_queue_cid_params rel;
81 struct ecore_queue_cid_params abs;
83 /* These have no 'relative' meaning */
90 /* VFs queues are mapped differently, so we need to know the
91 * relative queue associated with them [0-based].
92 * Notice this is relevant on the *PF* queue-cid of its VF's queues,
93 * and not on the VF itself.
98 /* We need an additional index to diffrentiate between queues opened
99 * for same queue-zone, as VFs would have to communicate the info
100 * to the PF [otherwise PF has no way to diffrentiate].
104 /* Legacy VFs might have Rx producer located elsewhere */
106 #define ECORE_QCID_LEGACY_VF_RX_PROD (1 << 0)
107 #define ECORE_QCID_LEGACY_VF_CID (1 << 1)
109 struct ecore_hwfn *p_owner;
112 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn);
113 void ecore_l2_setup(struct ecore_hwfn *p_hwfn);
114 void ecore_l2_free(struct ecore_hwfn *p_hwfn);
116 void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn,
117 struct ecore_queue_cid *p_cid);
119 struct ecore_queue_cid *
120 ecore_eth_queue_to_cid(struct ecore_hwfn *p_hwfn, u16 opaque_fid,
121 struct ecore_queue_start_common_params *p_params,
122 struct ecore_queue_cid_vf_params *p_vf_params);
125 ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn,
126 struct ecore_sp_vport_start_params *p_params);
129 * @brief - Starts an Rx queue, when queue_cid is already prepared
133 * @param bd_max_bytes
134 * @param bd_chain_phys_addr
135 * @param cqe_pbl_addr
136 * @param cqe_pbl_size
138 * @return enum _ecore_status_t
141 ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn,
142 struct ecore_queue_cid *p_cid,
144 dma_addr_t bd_chain_phys_addr,
145 dma_addr_t cqe_pbl_addr,
149 * @brief - Starts a Tx queue, where queue_cid is already prepared
155 * @param p_pq_params - parameters for choosing the PQ for this Tx queue
157 * @return enum _ecore_status_t
160 ecore_eth_txq_start_ramrod(struct ecore_hwfn *p_hwfn,
161 struct ecore_queue_cid *p_cid,
162 dma_addr_t pbl_addr, u16 pbl_size,
165 u8 ecore_mcast_bin_from_mac(u8 *mac);
168 * @brief - ecore_configure_rfs_ntuple_filter
170 * This ramrod should be used to add or remove arfs hw filter
174 * @params p_cb Used for ECORE_SPQ_MODE_CB,where client would initialize
175 it with cookie and callback function address, if not
176 using this mode then client must pass NULL.
177 * @params p_addr p_addr is an actual packet header that needs to be
178 * filter. It has to mapped with IO to read prior to
179 * calling this, [contains 4 tuples- src ip, dest ip,
180 * src port, dest port].
181 * @params length length of p_addr header up to past the transport header.
182 * @params qid receive packet will be directed to this queue.
184 * @params b_is_add flag to add or remove filter.
188 ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
189 struct ecore_ptt *p_ptt,
190 struct ecore_spq_comp_cb *p_cb,
191 dma_addr_t p_addr, u16 length,
192 u16 qid, u8 vport_id,