1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2021, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
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.
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.
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.
34 * @file ice_iflib_recovery_txrx.c
35 * @brief iflib Tx/Rx ops for recovery mode
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.
43 #include "ice_iflib.h"
46 * iflib txrx methods used when in recovery mode
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);
57 * @var ice_recovery_txrx
58 * @brief Tx/Rx operations for recovery mode
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.
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,
75 * ice_recovery_txd_encap - prepare Tx descriptors for a packet
76 * @arg: the iflib softc structure pointer
79 * Since the Tx queues are not initialized during recovery mode, this function
85 ice_recovery_txd_encap(void __unused *arg, if_pkt_info_t __unused pi)
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
96 * Since the Tx queues are not initialized during recovery mode, this function
100 ice_recovery_txd_flush(void __unused *arg, uint16_t __unused txqid,
101 qidx_t __unused pidx)
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
112 * Since the Tx queues are not initialized during recovery mode, this function
113 * always reports that no descriptors are ready.
118 ice_recovery_txd_credits_update(void __unused *arg, uint16_t __unused txqid,
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
131 * Since the Rx queues are not initialized during recovery mode, this function
132 * always reports that no packets are ready.
137 ice_recovery_rxd_available(void __unused *arg, uint16_t __unused rxqid,
138 qidx_t __unused pidx, qidx_t __unused budget)
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
148 * Since the Rx queues are not initialized during recovery mode this function
149 * always returns an error indicating that nothing could be done.
154 ice_recovery_rxd_pkt_get(void __unused *arg, if_rxd_info_t __unused ri)
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
164 * Since the Rx queues are not initialized during Recovery mode, this function
168 ice_recovery_rxd_refill(void __unused *arg, if_rxd_update_t __unused iru)
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
180 * Since the Rx queues are not initialized during Recovery mode, this function
184 ice_recovery_rxd_flush(void __unused *arg, uint16_t __unused rxqid,
185 uint8_t flidx __unused, qidx_t __unused pidx)