1 /****************************************************************************** 2 3 Copyright (c) 2013-2018, Intel Corporation 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 3. Neither the name of the Intel Corporation nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32 ******************************************************************************/ 33 34 35 #include "ixl_pf.h" 36 37 #ifndef _IXL_PF_QMGR_H_ 38 #define _IXL_PF_QMGR_H_ 39 40 /* 41 * Primarily manages the queues that need to be allocated to VSIs. 42 * 43 * Cardinality: There should only be one of these in a PF. 44 * Lifetime: Created and initialized in attach(); destroyed in detach(). 45 */ 46 47 #define IXL_MAX_SCATTERED_QUEUES 16 48 #define IXL_MAX_CONTIGUOUS_QUEUES_XL710 64 49 #define IXL_MAX_CONTIGUOUS_QUEUES_X722 128 50 51 /* Structures */ 52 53 /* Manager */ 54 struct ixl_pf_qmgr_qinfo { 55 u8 allocated; 56 u8 tx_enabled; 57 u8 rx_enabled; 58 u8 tx_configured; 59 u8 rx_configured; 60 }; 61 62 struct ixl_pf_qmgr { 63 u16 num_queues; 64 struct ixl_pf_qmgr_qinfo *qinfo; 65 }; 66 67 /* Tag */ 68 enum ixl_pf_qmgr_qalloc_type { 69 IXL_PF_QALLOC_CONTIGUOUS, 70 IXL_PF_QALLOC_SCATTERED 71 }; 72 73 struct ixl_pf_qtag { 74 struct ixl_pf_qmgr *qmgr; 75 enum ixl_pf_qmgr_qalloc_type type; 76 union { 77 u16 qidx[IXL_MAX_SCATTERED_QUEUES]; 78 u16 first_qidx; 79 }; 80 u16 num_allocated; 81 u16 num_active; 82 }; 83 84 /* Public manager functions */ 85 int ixl_pf_qmgr_init(struct ixl_pf_qmgr *qmgr, u16 num_queues); 86 void ixl_pf_qmgr_destroy(struct ixl_pf_qmgr *qmgr); 87 88 int ixl_pf_qmgr_get_num_queues(struct ixl_pf_qmgr *qmgr); 89 int ixl_pf_qmgr_get_first_free(struct ixl_pf_qmgr *qmgr, u16 start); 90 int ixl_pf_qmgr_get_num_free(struct ixl_pf_qmgr *qmgr); 91 92 /* Allocate queues for a VF VSI */ 93 int ixl_pf_qmgr_alloc_scattered(struct ixl_pf_qmgr *qmgr, u16 num, struct ixl_pf_qtag *qtag); 94 /* Allocate queues for the LAN VSIs, or X722 VF VSIs */ 95 int ixl_pf_qmgr_alloc_contiguous(struct ixl_pf_qmgr *qmgr, u16 num, struct ixl_pf_qtag *qtag); 96 /* Release a queue allocation */ 97 int ixl_pf_qmgr_release(struct ixl_pf_qmgr *qmgr, struct ixl_pf_qtag *qtag); 98 99 /* Help manage queues used in VFs */ 100 /* Typically hardware refers to RX as 0 and TX as 1, so continue that convention here */ 101 void ixl_pf_qmgr_mark_queue_enabled(struct ixl_pf_qtag *qtag, u16 vsi_qidx, bool tx); 102 void ixl_pf_qmgr_mark_queue_disabled(struct ixl_pf_qtag *qtag, u16 vsi_qidx, bool tx); 103 void ixl_pf_qmgr_mark_queue_configured(struct ixl_pf_qtag *qtag, u16 vsi_qidx, bool tx); 104 bool ixl_pf_qmgr_is_queue_enabled(struct ixl_pf_qtag *qtag, u16 vsi_qidx, bool tx); 105 bool ixl_pf_qmgr_is_queue_configured(struct ixl_pf_qtag *qtag, u16 vsi_qidx, bool tx); 106 void ixl_pf_qmgr_clear_queue_flags(struct ixl_pf_qtag *qtag); 107 108 /* Public tag functions */ 109 u16 ixl_pf_qidx_from_vsi_qidx(struct ixl_pf_qtag *qtag, u16 index); 110 111 #endif /* _IXL_PF_QMGR_H_ */ 112 113