111e25f0dSDavid C Somayajulu /* 211e25f0dSDavid C Somayajulu * Copyright (c) 2017-2018 Cavium, Inc. 311e25f0dSDavid C Somayajulu * All rights reserved. 411e25f0dSDavid C Somayajulu * 511e25f0dSDavid C Somayajulu * Redistribution and use in source and binary forms, with or without 611e25f0dSDavid C Somayajulu * modification, are permitted provided that the following conditions 711e25f0dSDavid C Somayajulu * are met: 811e25f0dSDavid C Somayajulu * 911e25f0dSDavid C Somayajulu * 1. Redistributions of source code must retain the above copyright 1011e25f0dSDavid C Somayajulu * notice, this list of conditions and the following disclaimer. 1111e25f0dSDavid C Somayajulu * 2. Redistributions in binary form must reproduce the above copyright 1211e25f0dSDavid C Somayajulu * notice, this list of conditions and the following disclaimer in the 1311e25f0dSDavid C Somayajulu * documentation and/or other materials provided with the distribution. 1411e25f0dSDavid C Somayajulu * 1511e25f0dSDavid C Somayajulu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1611e25f0dSDavid C Somayajulu * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1711e25f0dSDavid C Somayajulu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1811e25f0dSDavid C Somayajulu * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 1911e25f0dSDavid C Somayajulu * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2011e25f0dSDavid C Somayajulu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2111e25f0dSDavid C Somayajulu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2211e25f0dSDavid C Somayajulu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2311e25f0dSDavid C Somayajulu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2411e25f0dSDavid C Somayajulu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2511e25f0dSDavid C Somayajulu * POSSIBILITY OF SUCH DAMAGE. 2611e25f0dSDavid C Somayajulu * 2711e25f0dSDavid C Somayajulu */ 2811e25f0dSDavid C Somayajulu 2911e25f0dSDavid C Somayajulu #ifndef __ECORE_L2_H__ 3011e25f0dSDavid C Somayajulu #define __ECORE_L2_H__ 3111e25f0dSDavid C Somayajulu 3211e25f0dSDavid C Somayajulu #include "ecore.h" 3311e25f0dSDavid C Somayajulu #include "ecore_hw.h" 3411e25f0dSDavid C Somayajulu #include "ecore_spq.h" 3511e25f0dSDavid C Somayajulu #include "ecore_l2_api.h" 3611e25f0dSDavid C Somayajulu 3711e25f0dSDavid C Somayajulu #define MAX_QUEUES_PER_QZONE (sizeof(unsigned long) * 8) 3811e25f0dSDavid C Somayajulu #define ECORE_QUEUE_CID_PF (0xff) 3911e25f0dSDavid C Somayajulu 4011e25f0dSDavid C Somayajulu /* Almost identical to the ecore_queue_start_common_params, 4111e25f0dSDavid C Somayajulu * but here we maintain the SB index in IGU CAM. 4211e25f0dSDavid C Somayajulu */ 4311e25f0dSDavid C Somayajulu struct ecore_queue_cid_params { 4411e25f0dSDavid C Somayajulu u8 vport_id; 4511e25f0dSDavid C Somayajulu u16 queue_id; 4611e25f0dSDavid C Somayajulu u8 stats_id; 4711e25f0dSDavid C Somayajulu }; 4811e25f0dSDavid C Somayajulu 4911e25f0dSDavid C Somayajulu /* Additional parameters required for initialization of the queue_cid 5011e25f0dSDavid C Somayajulu * and are relevant only for a PF initializing one for its VFs. 5111e25f0dSDavid C Somayajulu */ 5211e25f0dSDavid C Somayajulu struct ecore_queue_cid_vf_params { 5311e25f0dSDavid C Somayajulu /* Should match the VF's relative index */ 5411e25f0dSDavid C Somayajulu u8 vfid; 5511e25f0dSDavid C Somayajulu 5611e25f0dSDavid C Somayajulu /* 0-based queue index. Should reflect the relative qzone the 5711e25f0dSDavid C Somayajulu * VF thinks is associated with it [in its range]. 5811e25f0dSDavid C Somayajulu */ 5911e25f0dSDavid C Somayajulu u8 vf_qid; 6011e25f0dSDavid C Somayajulu 6111e25f0dSDavid C Somayajulu /* Indicates a VF is legacy, making it differ in several things: 6211e25f0dSDavid C Somayajulu * - Producers would be placed in a different place. 6311e25f0dSDavid C Somayajulu * - Makes assumptions regarding the CIDs. 6411e25f0dSDavid C Somayajulu */ 6511e25f0dSDavid C Somayajulu u8 vf_legacy; 6611e25f0dSDavid C Somayajulu 6711e25f0dSDavid C Somayajulu /* For VFs, this index arrives via TLV to diffrentiate between 6811e25f0dSDavid C Somayajulu * different queues opened on the same qzone, and is passed 6911e25f0dSDavid C Somayajulu * [where the PF would have allocated it internally for its own]. 7011e25f0dSDavid C Somayajulu */ 7111e25f0dSDavid C Somayajulu u8 qid_usage_idx; 7211e25f0dSDavid C Somayajulu }; 7311e25f0dSDavid C Somayajulu 7411e25f0dSDavid C Somayajulu struct ecore_queue_cid { 7511e25f0dSDavid C Somayajulu /* For stats-id, the `rel' is actually absolute as well */ 7611e25f0dSDavid C Somayajulu struct ecore_queue_cid_params rel; 7711e25f0dSDavid C Somayajulu struct ecore_queue_cid_params abs; 7811e25f0dSDavid C Somayajulu 7911e25f0dSDavid C Somayajulu /* These have no 'relative' meaning */ 8011e25f0dSDavid C Somayajulu u16 sb_igu_id; 8111e25f0dSDavid C Somayajulu u8 sb_idx; 8211e25f0dSDavid C Somayajulu 8311e25f0dSDavid C Somayajulu u32 cid; 8411e25f0dSDavid C Somayajulu u16 opaque_fid; 8511e25f0dSDavid C Somayajulu 86*217ec208SDavid C Somayajulu bool b_is_rx; 87*217ec208SDavid C Somayajulu 8811e25f0dSDavid C Somayajulu /* VFs queues are mapped differently, so we need to know the 8911e25f0dSDavid C Somayajulu * relative queue associated with them [0-based]. 9011e25f0dSDavid C Somayajulu * Notice this is relevant on the *PF* queue-cid of its VF's queues, 9111e25f0dSDavid C Somayajulu * and not on the VF itself. 9211e25f0dSDavid C Somayajulu */ 9311e25f0dSDavid C Somayajulu u8 vfid; 9411e25f0dSDavid C Somayajulu u8 vf_qid; 9511e25f0dSDavid C Somayajulu 9611e25f0dSDavid C Somayajulu /* We need an additional index to diffrentiate between queues opened 9711e25f0dSDavid C Somayajulu * for same queue-zone, as VFs would have to communicate the info 9811e25f0dSDavid C Somayajulu * to the PF [otherwise PF has no way to diffrentiate]. 9911e25f0dSDavid C Somayajulu */ 10011e25f0dSDavid C Somayajulu u8 qid_usage_idx; 10111e25f0dSDavid C Somayajulu 10211e25f0dSDavid C Somayajulu /* Legacy VFs might have Rx producer located elsewhere */ 10311e25f0dSDavid C Somayajulu u8 vf_legacy; 10411e25f0dSDavid C Somayajulu #define ECORE_QCID_LEGACY_VF_RX_PROD (1 << 0) 10511e25f0dSDavid C Somayajulu #define ECORE_QCID_LEGACY_VF_CID (1 << 1) 10611e25f0dSDavid C Somayajulu 10711e25f0dSDavid C Somayajulu struct ecore_hwfn *p_owner; 10811e25f0dSDavid C Somayajulu }; 10911e25f0dSDavid C Somayajulu 11011e25f0dSDavid C Somayajulu enum _ecore_status_t ecore_l2_alloc(struct ecore_hwfn *p_hwfn); 11111e25f0dSDavid C Somayajulu void ecore_l2_setup(struct ecore_hwfn *p_hwfn); 11211e25f0dSDavid C Somayajulu void ecore_l2_free(struct ecore_hwfn *p_hwfn); 11311e25f0dSDavid C Somayajulu 11411e25f0dSDavid C Somayajulu void ecore_eth_queue_cid_release(struct ecore_hwfn *p_hwfn, 11511e25f0dSDavid C Somayajulu struct ecore_queue_cid *p_cid); 11611e25f0dSDavid C Somayajulu 11711e25f0dSDavid C Somayajulu struct ecore_queue_cid * 11811e25f0dSDavid C Somayajulu ecore_eth_queue_to_cid(struct ecore_hwfn *p_hwfn, u16 opaque_fid, 11911e25f0dSDavid C Somayajulu struct ecore_queue_start_common_params *p_params, 120*217ec208SDavid C Somayajulu bool b_is_rx, 12111e25f0dSDavid C Somayajulu struct ecore_queue_cid_vf_params *p_vf_params); 12211e25f0dSDavid C Somayajulu 12311e25f0dSDavid C Somayajulu enum _ecore_status_t 12411e25f0dSDavid C Somayajulu ecore_sp_eth_vport_start(struct ecore_hwfn *p_hwfn, 12511e25f0dSDavid C Somayajulu struct ecore_sp_vport_start_params *p_params); 12611e25f0dSDavid C Somayajulu 12711e25f0dSDavid C Somayajulu /** 12811e25f0dSDavid C Somayajulu * @brief - Starts an Rx queue, when queue_cid is already prepared 12911e25f0dSDavid C Somayajulu * 13011e25f0dSDavid C Somayajulu * @param p_hwfn 13111e25f0dSDavid C Somayajulu * @param p_cid 13211e25f0dSDavid C Somayajulu * @param bd_max_bytes 13311e25f0dSDavid C Somayajulu * @param bd_chain_phys_addr 13411e25f0dSDavid C Somayajulu * @param cqe_pbl_addr 13511e25f0dSDavid C Somayajulu * @param cqe_pbl_size 13611e25f0dSDavid C Somayajulu * 13711e25f0dSDavid C Somayajulu * @return enum _ecore_status_t 13811e25f0dSDavid C Somayajulu */ 13911e25f0dSDavid C Somayajulu enum _ecore_status_t 14011e25f0dSDavid C Somayajulu ecore_eth_rxq_start_ramrod(struct ecore_hwfn *p_hwfn, 14111e25f0dSDavid C Somayajulu struct ecore_queue_cid *p_cid, 14211e25f0dSDavid C Somayajulu u16 bd_max_bytes, 14311e25f0dSDavid C Somayajulu dma_addr_t bd_chain_phys_addr, 14411e25f0dSDavid C Somayajulu dma_addr_t cqe_pbl_addr, 14511e25f0dSDavid C Somayajulu u16 cqe_pbl_size); 14611e25f0dSDavid C Somayajulu 14711e25f0dSDavid C Somayajulu /** 14811e25f0dSDavid C Somayajulu * @brief - Starts a Tx queue, where queue_cid is already prepared 14911e25f0dSDavid C Somayajulu * 15011e25f0dSDavid C Somayajulu * @param p_hwfn 15111e25f0dSDavid C Somayajulu * @param p_cid 15211e25f0dSDavid C Somayajulu * @param pbl_addr 15311e25f0dSDavid C Somayajulu * @param pbl_size 15411e25f0dSDavid C Somayajulu * @param p_pq_params - parameters for choosing the PQ for this Tx queue 15511e25f0dSDavid C Somayajulu * 15611e25f0dSDavid C Somayajulu * @return enum _ecore_status_t 15711e25f0dSDavid C Somayajulu */ 15811e25f0dSDavid C Somayajulu enum _ecore_status_t 15911e25f0dSDavid C Somayajulu ecore_eth_txq_start_ramrod(struct ecore_hwfn *p_hwfn, 16011e25f0dSDavid C Somayajulu struct ecore_queue_cid *p_cid, 16111e25f0dSDavid C Somayajulu dma_addr_t pbl_addr, u16 pbl_size, 16211e25f0dSDavid C Somayajulu u16 pq_id); 16311e25f0dSDavid C Somayajulu 16411e25f0dSDavid C Somayajulu u8 ecore_mcast_bin_from_mac(u8 *mac); 165*217ec208SDavid C Somayajulu 166*217ec208SDavid C Somayajulu enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn, 167*217ec208SDavid C Somayajulu struct ecore_ptt *p_ptt, 168*217ec208SDavid C Somayajulu u16 coalesce, 169*217ec208SDavid C Somayajulu struct ecore_queue_cid *p_cid); 170*217ec208SDavid C Somayajulu 171*217ec208SDavid C Somayajulu enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn, 172*217ec208SDavid C Somayajulu struct ecore_ptt *p_ptt, 173*217ec208SDavid C Somayajulu u16 coalesce, 174*217ec208SDavid C Somayajulu struct ecore_queue_cid *p_cid); 175*217ec208SDavid C Somayajulu 176*217ec208SDavid C Somayajulu enum _ecore_status_t ecore_get_rxq_coalesce(struct ecore_hwfn *p_hwfn, 177*217ec208SDavid C Somayajulu struct ecore_ptt *p_ptt, 178*217ec208SDavid C Somayajulu struct ecore_queue_cid *p_cid, 179*217ec208SDavid C Somayajulu u16 *p_hw_coal); 180*217ec208SDavid C Somayajulu 181*217ec208SDavid C Somayajulu enum _ecore_status_t ecore_get_txq_coalesce(struct ecore_hwfn *p_hwfn, 182*217ec208SDavid C Somayajulu struct ecore_ptt *p_ptt, 183*217ec208SDavid C Somayajulu struct ecore_queue_cid *p_cid, 184*217ec208SDavid C Somayajulu u16 *p_hw_coal); 185*217ec208SDavid C Somayajulu 18611e25f0dSDavid C Somayajulu #endif 187