New upstream version 18.08
[deb_dpdk.git] / drivers / net / qede / base / ecore_l2.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.com
5  */
6
7 #ifndef __ECORE_L2_H__
8 #define __ECORE_L2_H__
9
10
11 #include "ecore.h"
12 #include "ecore_hw.h"
13 #include "ecore_spq.h"
14 #include "ecore_l2_api.h"
15
16 #define MAX_QUEUES_PER_QZONE    (sizeof(unsigned long) * 8)
17 #define ECORE_QUEUE_CID_PF      (0xff)
18
19 /* Almost identical to the ecore_queue_start_common_params,
20  * but here we maintain the SB index in IGU CAM.
21  */
22 struct ecore_queue_cid_params {
23         u8 vport_id;
24         u16 queue_id;
25         u8 stats_id;
26 };
27
28  /* Additional parameters required for initialization of the queue_cid
29  * and are relevant only for a PF initializing one for its VFs.
30  */
31 struct ecore_queue_cid_vf_params {
32         /* Should match the VF's relative index */
33         u8 vfid;
34
35         /* 0-based queue index. Should reflect the relative qzone the
36          * VF thinks is associated with it [in its range].
37          */
38         u8 vf_qid;
39
40         /* Indicates a VF is legacy, making it differ in several things:
41          *  - Producers would be placed in a different place.
42          *  - Makes assumptions regarding the CIDs.
43          */
44         u8 vf_legacy;
45
46         /* For VFs, this index arrives via TLV to diffrentiate between
47          * different queues opened on the same qzone, and is passed
48          * [where the PF would have allocated it internally for its own].
49          */
50         u8 qid_usage_idx;
51 };
52
53 struct ecore_queue_cid {
54         /* For stats-id, the `rel' is actually absolute as well */
55         struct ecore_queue_cid_params rel;
56         struct ecore_queue_cid_params abs;
57
58         /* These have no 'relative' meaning */
59         u16 sb_igu_id;
60         u8 sb_idx;
61
62         u32 cid;
63         u16 opaque_fid;
64
65         bool b_is_rx;
66
67         /* VFs queues are mapped differently, so we need to know the
68          * relative queue associated with them [0-based].
69          * Notice this is relevant on the *PF* queue-cid of its VF's queues,
70          * and not on the VF itself.
71          */
72         u8 vfid;
73         u8 vf_qid;
74
75         /* We need an additional index to diffrentiate between queues opened
76          * for same queue-zone, as VFs would have to communicate the info
77          * to the PF [otherwise PF has no way to diffrentiate].
78          */
79         u8 qid_usage_idx;
80
81         /* Legacy VFs might have Rx producer located elsewhere */
82         u8 vf_legacy;
83 #define ECORE_QCID_LEGACY_VF_RX_PROD    (1 << 0)
84 #define ECORE_QCID_LEGACY_VF_CID        (1 << 1)
85
86         struct ecore_hwfn *p_owner;
87 };
88
89 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn);
90 void ecore_l2_setup(struct ecore_hwfn *p_hwfn);
91 void ecore_l2_free(struct ecore_hwfn *p_hwfn);
92
93 void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn,
94                                  struct ecore_queue_cid *p_cid);
95
96 struct ecore_queue_cid *
97 ecore_eth_queue_to_cid(struct ecore_hwfn *p_hwfn, u16 opaque_fid,
98                        struct ecore_queue_start_common_params *p_params,
99                        bool b_is_rx,
100                        struct ecore_queue_cid_vf_params *p_vf_params);
101
102 enum _ecore_status_t
103 ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn,
104                          struct ecore_sp_vport_start_params *p_params);
105
106 /**
107  * @brief - Starts an Rx queue, when queue_cid is already prepared
108  *
109  * @param p_hwfn
110  * @param p_cid
111  * @param bd_max_bytes
112  * @param bd_chain_phys_addr
113  * @param cqe_pbl_addr
114  * @param cqe_pbl_size
115  *
116  * @return enum _ecore_status_t
117  */
118 enum _ecore_status_t
119 ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn,
120                            struct ecore_queue_cid *p_cid,
121                            u16 bd_max_bytes,
122                            dma_addr_t bd_chain_phys_addr,
123                            dma_addr_t cqe_pbl_addr,
124                            u16 cqe_pbl_size);
125
126 /**
127  * @brief - Starts a Tx queue, where queue_cid is already prepared
128  *
129  * @param p_hwfn
130  * @param p_cid
131  * @param pbl_addr
132  * @param pbl_size
133  * @param p_pq_params - parameters for choosing the PQ for this Tx queue
134  *
135  * @return enum _ecore_status_t
136  */
137 enum _ecore_status_t
138 ecore_eth_txq_start_ramrod(struct ecore_hwfn *p_hwfn,
139                            struct ecore_queue_cid *p_cid,
140                            dma_addr_t pbl_addr, u16 pbl_size,
141                            u16 pq_id);
142
143 u8 ecore_mcast_bin_from_mac(u8 *mac);
144
145 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn,
146                                             struct ecore_ptt *p_ptt,
147                                             u16 coalesce,
148                                             struct ecore_queue_cid *p_cid);
149
150 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn,
151                                             struct ecore_ptt *p_ptt,
152                                             u16 coalesce,
153                                             struct ecore_queue_cid *p_cid);
154
155 enum _ecore_status_t ecore_get_rxq_coalesce(struct ecore_hwfn *p_hwfn,
156                                             struct ecore_ptt *p_ptt,
157                                             struct ecore_queue_cid *p_cid,
158                                             u16 *p_hw_coal);
159
160 enum _ecore_status_t ecore_get_txq_coalesce(struct ecore_hwfn *p_hwfn,
161                                             struct ecore_ptt *p_ptt,
162                                             struct ecore_queue_cid *p_cid,
163                                             u16 *p_hw_coal);
164
165 #endif