1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright (c) 2023, 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 32 /** 33 * @file ice_iflib_recovery_txrx.c 34 * @brief iflib Tx/Rx ops for recovery mode 35 * 36 * Contains the if_txrx structure of operations used when the driver detects 37 * that the firmware is in recovery mode. These ops essentially do nothing and 38 * exist to prevent any chance that the stack could attempt to transmit or 39 * receive when the device is in firmware recovery mode. 40 */ 41 42 #include "ice_iflib.h" 43 44 /* 45 * iflib txrx methods used when in recovery mode 46 */ 47 static int ice_recovery_txd_encap(void *arg, if_pkt_info_t pi); 48 static int ice_recovery_rxd_pkt_get(void *arg, if_rxd_info_t ri); 49 static void ice_recovery_txd_flush(void *arg, uint16_t txqid, qidx_t pidx); 50 static int ice_recovery_txd_credits_update(void *arg, uint16_t txqid, bool clear); 51 static int ice_recovery_rxd_available(void *arg, uint16_t rxqid, qidx_t pidx, qidx_t budget); 52 static void ice_recovery_rxd_flush(void *arg, uint16_t rxqid, uint8_t flidx, qidx_t pidx); 53 static void ice_recovery_rxd_refill(void *arg, if_rxd_update_t iru); 54 55 /** 56 * @var ice_recovery_txrx 57 * @brief Tx/Rx operations for recovery mode 58 * 59 * Similar to ice_txrx, but contains pointers to functions which are no-ops. 60 * Used when the driver is in firmware recovery mode to prevent any attempt to 61 * transmit or receive packets while the hardware is not initialized. 62 */ 63 struct if_txrx ice_recovery_txrx = { 64 .ift_txd_encap = ice_recovery_txd_encap, 65 .ift_txd_flush = ice_recovery_txd_flush, 66 .ift_txd_credits_update = ice_recovery_txd_credits_update, 67 .ift_rxd_available = ice_recovery_rxd_available, 68 .ift_rxd_pkt_get = ice_recovery_rxd_pkt_get, 69 .ift_rxd_refill = ice_recovery_rxd_refill, 70 .ift_rxd_flush = ice_recovery_rxd_flush, 71 }; 72 73 /** 74 * ice_recovery_txd_encap - prepare Tx descriptors for a packet 75 * @arg: the iflib softc structure pointer 76 * @pi: packet info 77 * 78 * Since the Tx queues are not initialized during recovery mode, this function 79 * does nothing. 80 * 81 * @returns ENOSYS 82 */ 83 static int 84 ice_recovery_txd_encap(void __unused *arg, if_pkt_info_t __unused pi) 85 { 86 return (ENOSYS); 87 } 88 89 /** 90 * ice_recovery_txd_flush - Flush Tx descriptors to hardware 91 * @arg: device specific softc pointer 92 * @txqid: the Tx queue to flush 93 * @pidx: descriptor index to advance tail to 94 * 95 * Since the Tx queues are not initialized during recovery mode, this function 96 * does nothing. 97 */ 98 static void 99 ice_recovery_txd_flush(void __unused *arg, uint16_t __unused txqid, 100 qidx_t __unused pidx) 101 { 102 ; 103 } 104 105 /** 106 * ice_recovery_txd_credits_update - cleanup Tx descriptors 107 * @arg: device private softc 108 * @txqid: the Tx queue to update 109 * @clear: if false, only report, do not actually clean 110 * 111 * Since the Tx queues are not initialized during recovery mode, this function 112 * always reports that no descriptors are ready. 113 * 114 * @returns 0 115 */ 116 static int 117 ice_recovery_txd_credits_update(void __unused *arg, uint16_t __unused txqid, 118 bool __unused clear) 119 { 120 return (0); 121 } 122 123 /** 124 * ice_recovery_rxd_available - Return number of available Rx packets 125 * @arg: device private softc 126 * @rxqid: the Rx queue id 127 * @pidx: descriptor start point 128 * @budget: maximum Rx budget 129 * 130 * Since the Rx queues are not initialized during recovery mode, this function 131 * always reports that no packets are ready. 132 * 133 * @returns 0 134 */ 135 static int 136 ice_recovery_rxd_available(void __unused *arg, uint16_t __unused rxqid, 137 qidx_t __unused pidx, qidx_t __unused budget) 138 { 139 return (0); 140 } 141 142 /** 143 * ice_recovery_rxd_pkt_get - Called by iflib to send data to upper layer 144 * @arg: device specific softc 145 * @ri: receive packet info 146 * 147 * Since the Rx queues are not initialized during recovery mode this function 148 * always returns an error indicating that nothing could be done. 149 * 150 * @returns ENOSYS 151 */ 152 static int 153 ice_recovery_rxd_pkt_get(void __unused *arg, if_rxd_info_t __unused ri) 154 { 155 return (ENOSYS); 156 } 157 158 /** 159 * ice_recovery_rxd_refill - Prepare Rx descriptors for re-use by hardware 160 * @arg: device specific softc structure 161 * @iru: the Rx descriptor update structure 162 * 163 * Since the Rx queues are not initialized during Recovery mode, this function 164 * does nothing. 165 */ 166 static void 167 ice_recovery_rxd_refill(void __unused *arg, if_rxd_update_t __unused iru) 168 { 169 ; 170 } 171 172 /** 173 * ice_recovery_rxd_flush - Flush Rx descriptors to hardware 174 * @arg: device specific softc pointer 175 * @rxqid: the Rx queue to flush 176 * @flidx: unused parameter 177 * @pidx: descriptor index to advance tail to 178 * 179 * Since the Rx queues are not initialized during Recovery mode, this function 180 * does nothing. 181 */ 182 static void 183 ice_recovery_rxd_flush(void __unused *arg, uint16_t __unused rxqid, 184 uint8_t flidx __unused, qidx_t __unused pidx) 185 { 186 ; 187 } 188