]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/qlnx/qlnxe/ecore_l2.h
MFC r316485
[FreeBSD/stable/10.git] / sys / dev / qlnx / qlnxe / ecore_l2.h
1 /*
2  * Copyright (c) 2017-2018 Cavium, Inc. 
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
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.
14  *
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.
26  *
27  * $FreeBSD$
28  *
29  */
30
31
32 #ifndef __ECORE_L2_H__
33 #define __ECORE_L2_H__
34
35
36 #include "ecore.h"
37 #include "ecore_hw.h"
38 #include "ecore_spq.h"
39 #include "ecore_l2_api.h"
40
41 #define MAX_QUEUES_PER_QZONE    (sizeof(unsigned long) * 8)
42 #define ECORE_QUEUE_CID_PF      (0xff)
43
44 /* Almost identical to the ecore_queue_start_common_params,
45  * but here we maintain the SB index in IGU CAM.
46  */
47 struct ecore_queue_cid_params {
48         u8 vport_id;
49         u16 queue_id;
50         u8 stats_id;
51 };
52
53  /* Additional parameters required for initialization of the queue_cid
54  * and are relevant only for a PF initializing one for its VFs.
55  */
56 struct ecore_queue_cid_vf_params {
57         /* Should match the VF's relative index */
58         u8 vfid;
59
60         /* 0-based queue index. Should reflect the relative qzone the
61          * VF thinks is associated with it [in its range].
62          */
63         u8 vf_qid;
64
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.
68          */
69         u8 vf_legacy;
70
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].
74          */
75         u8 qid_usage_idx;
76 };
77
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;
82
83         /* These have no 'relative' meaning */
84         u16 sb_igu_id;
85         u8 sb_idx;
86
87         u32 cid;
88         u16 opaque_fid;
89
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.
94          */
95         u8 vfid;
96         u8 vf_qid;
97
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].
101          */
102         u8 qid_usage_idx;
103
104         /* Legacy VFs might have Rx producer located elsewhere */
105         u8 vf_legacy;
106 #define ECORE_QCID_LEGACY_VF_RX_PROD    (1 << 0)
107 #define ECORE_QCID_LEGACY_VF_CID        (1 << 1)
108
109         struct ecore_hwfn *p_owner;
110 };
111
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);
115
116 void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn,
117                                  struct ecore_queue_cid *p_cid);
118
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);
123
124 enum _ecore_status_t
125 ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn,
126                          struct ecore_sp_vport_start_params *p_params);
127
128 /**
129  * @brief - Starts an Rx queue, when queue_cid is already prepared
130  *
131  * @param p_hwfn
132  * @param p_cid
133  * @param bd_max_bytes
134  * @param bd_chain_phys_addr
135  * @param cqe_pbl_addr
136  * @param cqe_pbl_size
137  *
138  * @return enum _ecore_status_t
139  */
140 enum _ecore_status_t
141 ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn,
142                            struct ecore_queue_cid *p_cid,
143                            u16 bd_max_bytes,
144                            dma_addr_t bd_chain_phys_addr,
145                            dma_addr_t cqe_pbl_addr,
146                            u16 cqe_pbl_size);
147
148 /**
149  * @brief - Starts a Tx queue, where queue_cid is already prepared
150  *
151  * @param p_hwfn
152  * @param p_cid
153  * @param pbl_addr 
154  * @param pbl_size
155  * @param p_pq_params - parameters for choosing the PQ for this Tx queue
156  *
157  * @return enum _ecore_status_t
158  */
159 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,
163                            u16 pq_id);
164
165 u8 ecore_mcast_bin_from_mac(u8 *mac);
166
167 /**
168  * @brief - ecore_configure_rfs_ntuple_filter
169  *
170  * This ramrod should be used to add or remove arfs hw filter
171  *
172  * @params p_hwfn
173  * @params p_ptt
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.
183  * @params vport_id
184  * @params b_is_add     flag to add or remove filter.
185  *
186  */
187 enum _ecore_status_t
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,
193                                   bool b_is_add);
194 #endif