7fe4cbcb37c668de28a07def7409e67987ce0103
[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 /* 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         bool b_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         bool b_legacy_vf;
73
74         struct ecore_hwfn *p_owner;
75 };
76
77 enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn);
78 void ecore_l2_setup(struct ecore_hwfn *p_hwfn);
79 void ecore_l2_free(struct ecore_hwfn *p_hwfn);
80
81 void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn,
82                                  struct ecore_queue_cid *p_cid);
83
84 struct ecore_queue_cid *
85 ecore_eth_queue_to_cid(struct ecore_hwfn *p_hwfn, u16 opaque_fid,
86                        struct ecore_queue_start_common_params *p_params,
87                        struct ecore_queue_cid_vf_params *p_vf_params);
88
89 enum _ecore_status_t
90 ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn,
91                          struct ecore_sp_vport_start_params *p_params);
92
93 /**
94  * @brief - Starts an Rx queue, when queue_cid is already prepared
95  *
96  * @param p_hwfn
97  * @param p_cid
98  * @param bd_max_bytes
99  * @param bd_chain_phys_addr
100  * @param cqe_pbl_addr
101  * @param cqe_pbl_size
102  *
103  * @return enum _ecore_status_t
104  */
105 enum _ecore_status_t
106 ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn,
107                            struct ecore_queue_cid *p_cid,
108                            u16 bd_max_bytes,
109                            dma_addr_t bd_chain_phys_addr,
110                            dma_addr_t cqe_pbl_addr,
111                            u16 cqe_pbl_size);
112
113 /**
114  * @brief - Starts a Tx queue, where queue_cid is already prepared
115  *
116  * @param p_hwfn
117  * @param p_cid
118  * @param pbl_addr
119  * @param pbl_size
120  * @param p_pq_params - parameters for choosing the PQ for this Tx queue
121  *
122  * @return enum _ecore_status_t
123  */
124 enum _ecore_status_t
125 ecore_eth_txq_start_ramrod(struct ecore_hwfn *p_hwfn,
126                            struct ecore_queue_cid *p_cid,
127                            dma_addr_t pbl_addr, u16 pbl_size,
128                            u16 pq_id);
129
130 u8 ecore_mcast_bin_from_mac(u8 *mac);
131
132 /**
133  * @brief - ecore_configure_rfs_ntuple_filter
134  *
135  * This ramrod should be used to add or remove arfs hw filter
136  *
137  * @params p_hwfn
138  * @params p_ptt
139  * @params p_cb         Used for ECORE_SPQ_MODE_CB,where client would initialize
140                         it with cookie and callback function address, if not
141                         using this mode then client must pass NULL.
142  * @params p_addr       p_addr is an actual packet header that needs to be
143  *                      filter. It has to mapped with IO to read prior to
144  *                      calling this, [contains 4 tuples- src ip, dest ip,
145  *                      src port, dest port].
146  * @params length       length of p_addr header up to past the transport header.
147  * @params qid          receive packet will be directed to this queue.
148  * @params vport_id
149  * @params b_is_add     flag to add or remove filter.
150  *
151  */
152 enum _ecore_status_t
153 ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
154                                   struct ecore_ptt *p_ptt,
155                                   struct ecore_spq_comp_cb *p_cb,
156                                   dma_addr_t p_addr, u16 length,
157                                   u16 qid, u8 vport_id,
158                                   bool b_is_add);
159 #endif