1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright (c) 2020, Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the Intel Corporation nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 /*$FreeBSD$*/ 32 33 /** 34 * @file ice_iflib_recovery_txrx.c 35 * @brief iflib Tx/Rx ops for recovery mode 36 * 37 * Contains the if_txrx structure of operations used when the driver detects 38 * that the firmware is in recovery mode. These ops essentially do nothing and 39 * exist to prevent any chance that the stack could attempt to transmit or 40 * receive when the device is in firmware recovery mode. 41 */ 42 43 #include "ice_iflib.h" 44 45 /* 46 * iflib txrx methods used when in recovery mode 47 */ 48 static int ice_recovery_txd_encap(void *arg, if_pkt_info_t pi); 49 static int ice_recovery_rxd_pkt_get(void *arg, if_rxd_info_t ri); 50 static void ice_recovery_txd_flush(void *arg, uint16_t txqid, qidx_t pidx); 51 static int ice_recovery_txd_credits_update(void *arg, uint16_t txqid, bool clear); 52 static int ice_recovery_rxd_available(void *arg, uint16_t rxqid, qidx_t pidx, qidx_t budget); 53 static void ice_recovery_rxd_flush(void *arg, uint16_t rxqid, uint8_t flidx, qidx_t pidx); 54 static void ice_recovery_rxd_refill(void *arg, if_rxd_update_t iru); 55 56 /** 57 * @var ice_recovery_txrx 58 * @brief Tx/Rx operations for recovery mode 59 * 60 * Similar to ice_txrx, but contains pointers to functions which are no-ops. 61 * Used when the driver is in firmware recovery mode to prevent any attempt to 62 * transmit or receive packets while the hardware is not initialized. 63 */ 64 struct if_txrx ice_recovery_txrx = { 65 .ift_txd_encap = ice_recovery_txd_encap, 66 .ift_txd_flush = ice_recovery_txd_flush, 67 .ift_txd_credits_update = ice_recovery_txd_credits_update, 68 .ift_rxd_available = ice_recovery_rxd_available, 69 .ift_rxd_pkt_get = ice_recovery_rxd_pkt_get, 70 .ift_rxd_refill = ice_recovery_rxd_refill, 71 .ift_rxd_flush = ice_recovery_rxd_flush, 72 }; 73 74 /** 75 * ice_recovery_txd_encap - prepare Tx descriptors for a packet 76 * @arg: the iflib softc structure pointer 77 * @pi: packet info 78 * 79 * Since the Tx queues are not initialized during recovery mode, this function 80 * does nothing. 81 * 82 * @returns ENOSYS 83 */ 84 static int 85 ice_recovery_txd_encap(void __unused *arg, if_pkt_info_t __unused pi) 86 { 87 return (ENOSYS); 88 } 89 90 /** 91 * ice_recovery_txd_flush - Flush Tx descriptors to hardware 92 * @arg: device specific softc pointer 93 * @txqid: the Tx queue to flush 94 * @pidx: descriptor index to advance tail to 95 * 96 * Since the Tx queues are not initialized during recovery mode, this function 97 * does nothing. 98 */ 99 static void 100 ice_recovery_txd_flush(void __unused *arg, uint16_t __unused txqid, 101 qidx_t __unused pidx) 102 { 103 ; 104 } 105 106 /** 107 * ice_recovery_txd_credits_update - cleanup Tx descriptors 108 * @arg: device private softc 109 * @txqid: the Tx queue to update 110 * @clear: if false, only report, do not actually clean 111 * 112 * Since the Tx queues are not initialized during recovery mode, this function 113 * always reports that no descriptors are ready. 114 * 115 * @returns 0 116 */ 117 static int 118 ice_recovery_txd_credits_update(void __unused *arg, uint16_t __unused txqid, 119 bool __unused clear) 120 { 121 return (0); 122 } 123 124 /** 125 * ice_recovery_rxd_available - Return number of available Rx packets 126 * @arg: device private softc 127 * @rxqid: the Rx queue id 128 * @pidx: descriptor start point 129 * @budget: maximum Rx budget 130 * 131 * Since the Rx queues are not initialized during recovery mode, this function 132 * always reports that no packets are ready. 133 * 134 * @returns 0 135 */ 136 static int 137 ice_recovery_rxd_available(void __unused *arg, uint16_t __unused rxqid, 138 qidx_t __unused pidx, qidx_t __unused budget) 139 { 140 return (0); 141 } 142 143 /** 144 * ice_recovery_rxd_pkt_get - Called by iflib to send data to upper layer 145 * @arg: device specific softc 146 * @ri: receive packet info 147 * 148 * Since the Rx queues are not initialized during recovery mode this function 149 * always returns an error indicating that nothing could be done. 150 * 151 * @returns ENOSYS 152 */ 153 static int 154 ice_recovery_rxd_pkt_get(void __unused *arg, if_rxd_info_t __unused ri) 155 { 156 return (ENOSYS); 157 } 158 159 /** 160 * ice_recovery_rxd_refill - Prepare Rx descriptors for re-use by hardware 161 * @arg: device specific softc structure 162 * @iru: the Rx descriptor update structure 163 * 164 * Since the Rx queues are not initialized during Recovery mode, this function 165 * does nothing. 166 */ 167 static void 168 ice_recovery_rxd_refill(void __unused *arg, if_rxd_update_t __unused iru) 169 { 170 ; 171 } 172 173 /** 174 * ice_recovery_rxd_flush - Flush Rx descriptors to hardware 175 * @arg: device specific softc pointer 176 * @rxqid: the Rx queue to flush 177 * @flidx: unused parameter 178 * @pidx: descriptor index to advance tail to 179 * 180 * Since the Rx queues are not initialized during Recovery mode, this function 181 * does nothing. 182 */ 183 static void 184 ice_recovery_rxd_flush(void __unused *arg, uint16_t __unused rxqid, 185 uint8_t flidx __unused, qidx_t __unused pidx) 186 { 187 ; 188 } 189