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