net/qede/base: changes for VF queue zone
[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 /* Additional parameters required for initialization of the queue_cid
22  * and are relevant only for a PF initializing one for its VFs.
23  */
24 struct ecore_queue_cid_vf_params {
25         /* Should match the VF's relative index */
26         u8 vfid;
27
28         /* 0-based queue index. Should reflect the relative qzone the
29          * VF thinks is associated with it [in its range].
30          */
31         u8 vf_qid;
32
33         /* Indicates a VF is legacy, making it differ in several things:
34          *  - Producers would be placed in a different place.
35          *  - Makes assumptions regarding the CIDs.
36          */
37         u8 vf_legacy;
38
39         /* For VFs, this index arrives via TLV to diffrentiate between
40          * different queues opened on the same qzone, and is passed
41          * [where the PF would have allocated it internally for its own].
42          */
43         u8 qid_usage_idx;
44 };
45
46 struct ecore_queue_cid {
47         /* 'Relative' is a relative term ;-). Usually the indices [not counting
48          * SBs] would be PF-relative, but there are some cases where that isn't
49          * the case - specifically for a PF configuring its VF indices it's
50          * possible some fields [E.g., stats-id] in 'rel' would already be abs.
51          */
52         struct ecore_queue_start_common_params rel;
53         struct ecore_queue_start_common_params abs;
54         u32 cid;
55         u16 opaque_fid;
56
57         /* VFs queues are mapped differently, so we need to know the
58          * relative queue associated with them [0-based].
59          * Notice this is relevant on the *PF* queue-cid of its VF's queues,
60          * and not on the VF itself.
61          */
62         u8 vfid;
63         u8 vf_qid;
64
65         /* We need an additional index to diffrentiate between queues opened
66          * for same queue-zone, as VFs would have to communicate the info
67          * to the PF [otherwise PF has no way to diffrentiate].
68          */
69         u8 qid_usage_idx;
70
71         /* Legacy VFs might have Rx producer located elsewhere */
72         u8 vf_legacy;
73 #define ECORE_QCID_LEGACY_VF_RX_PROD    (1 << 0)
74 #define ECORE_QCID_LEGACY_VF_CID        (1 << 1)
75
76         struct ecore_hwfn *p_owner;
77 };
78
79 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn);
80 void ecore_l2_setup(struct ecore_hwfn *p_hwfn);
81 void ecore_l2_free(struct ecore_hwfn *p_hwfn);
82
83 void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn,
84                                  struct ecore_queue_cid *p_cid);
85
86 struct ecore_queue_cid *
87 ecore_eth_queue_to_cid(struct ecore_hwfn *p_hwfn, u16 opaque_fid,
88                        struct ecore_queue_start_common_params *p_params,
89                        struct ecore_queue_cid_vf_params *p_vf_params);
90
91 enum _ecore_status_t
92 ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn,
93                          struct ecore_sp_vport_start_params *p_params);
94
95 /**
96  * @brief - Starts an Rx queue, when queue_cid is already prepared
97  *
98  * @param p_hwfn
99  * @param p_cid
100  * @param bd_max_bytes
101  * @param bd_chain_phys_addr
102  * @param cqe_pbl_addr
103  * @param cqe_pbl_size
104  *
105  * @return enum _ecore_status_t
106  */
107 enum _ecore_status_t
108 ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn,
109                            struct ecore_queue_cid *p_cid,
110                            u16 bd_max_bytes,
111                            dma_addr_t bd_chain_phys_addr,
112                            dma_addr_t cqe_pbl_addr,
113                            u16 cqe_pbl_size);
114
115 /**
116  * @brief - Starts a Tx queue, where queue_cid is already prepared
117  *
118  * @param p_hwfn
119  * @param p_cid
120  * @param pbl_addr
121  * @param pbl_size
122  * @param p_pq_params - parameters for choosing the PQ for this Tx queue
123  *
124  * @return enum _ecore_status_t
125  */
126 enum _ecore_status_t
127 ecore_eth_txq_start_ramrod(struct ecore_hwfn *p_hwfn,
128                            struct ecore_queue_cid *p_cid,
129                            dma_addr_t pbl_addr, u16 pbl_size,
130                            u16 pq_id);
131
132 u8 ecore_mcast_bin_from_mac(u8 *mac);
133
134 /**
135  * @brief - ecore_configure_rfs_ntuple_filter
136  *
137  * This ramrod should be used to add or remove arfs hw filter
138  *
139  * @params p_hwfn
140  * @params p_ptt
141  * @params p_cb         Used for ECORE_SPQ_MODE_CB,where client would initialize
142                         it with cookie and callback function address, if not
143                         using this mode then client must pass NULL.
144  * @params p_addr       p_addr is an actual packet header that needs to be
145  *                      filter. It has to mapped with IO to read prior to
146  *                      calling this, [contains 4 tuples- src ip, dest ip,
147  *                      src port, dest port].
148  * @params length       length of p_addr header up to past the transport header.
149  * @params qid          receive packet will be directed to this queue.
150  * @params vport_id
151  * @params b_is_add     flag to add or remove filter.
152  *
153  */
154 enum _ecore_status_t
155 ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
156                                   struct ecore_ptt *p_ptt,
157                                   struct ecore_spq_comp_cb *p_cb,
158                                   dma_addr_t p_addr, u16 length,
159                                   u16 qid, u8 vport_id,
160                                   bool b_is_add);
161 #endif