1 /* 2 * Copyright (c) 2012-2014, 2016-2018, 2020 The Linux Foundation. 3 * All rights reserved. 4 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 5 * 6 * Permission to use, copy, modify, and/or distribute this software for 7 * any purpose with or without fee is hereby granted, provided that the 8 * above copyright notice and this permission notice appear in all 9 * copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 15 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 16 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 17 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 18 * PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21 /* 22 * The file is used to define structures that are shared between 23 * kernel space and user space pktlog application. 24 */ 25 26 #ifndef _PKTLOG_AC_API_ 27 #define _PKTLOG_AC_API_ 28 #if defined(CONNECTIVITY_PKTLOG) || !defined(REMOVE_PKT_LOG) 29 30 /** 31 * @typedef ol_pktlog_dev_handle 32 * @brief opaque handle for pktlog device object 33 */ 34 struct ol_pktlog_dev_t; 35 36 /** 37 * @typedef hif_opaque_softc_handle 38 * @brief opaque handle for hif_opaque_softc 39 */ 40 struct hif_opaque_softc; 41 typedef struct hif_opaque_softc *hif_opaque_softc_handle; 42 43 enum pktlog_callback_regtype { 44 PKTLOG_DEFAULT_CALLBACK_REGISTRATION, 45 PKTLOG_LITE_CALLBACK_REGISTRATION 46 }; 47 48 /** 49 * @typedef net_device_handle 50 * @brief opaque handle linux phy device object 51 */ 52 struct net_device; 53 typedef struct net_device *net_device_handle; 54 55 struct pktlog_dev_t; 56 57 void pktlog_sethandle(struct pktlog_dev_t **pl_handle, 58 hif_opaque_softc_handle scn); 59 void pktlog_set_pdev_id(struct pktlog_dev_t *pl_dev, uint8_t pdev_id); 60 61 void *get_txrx_context(void); 62 63 struct pktlog_dev_t *get_pktlog_handle(void); 64 void pktlog_set_callback_regtype(enum pktlog_callback_regtype callback_type); 65 66 /* Packet log state information */ 67 #ifndef _PKTLOG_INFO 68 #define _PKTLOG_INFO 69 70 /** 71 * enum ath_pktlog_state - pktlog status 72 * @PKTLOG_OPR_IN_PROGRESS : pktlog command in progress 73 * @PKTLOG_OPR_IN_PROGRESS_READ_START: pktlog read is issued 74 * @PKTLOG_OPR_IN_PROGRESS_READ_START_PKTLOG_DISABLED: 75 * as part of pktlog read, pktlog is disabled 76 * @PKTLOG_OPR_IN_PROGRESS_READ_COMPLETE: 77 * as part of read, till pktlog read is complete 78 * @PKTLOG_OPR_IN_PROGRESS_CLEARBUFF_COMPLETE: 79 * as part of read, pktlog clear buffer is done 80 * @PKTLOG_OPR_NOT_IN_PROGRESS: no pktlog command in progress 81 */ 82 enum ath_pktlog_state { 83 PKTLOG_OPR_IN_PROGRESS = 0, 84 PKTLOG_OPR_IN_PROGRESS_READ_START, 85 PKTLOG_OPR_IN_PROGRESS_READ_START_PKTLOG_DISABLED, 86 PKTLOG_OPR_IN_PROGRESS_READ_COMPLETE, 87 PKTLOG_OPR_IN_PROGRESS_CLEARBUFF_COMPLETE, 88 PKTLOG_OPR_NOT_IN_PROGRESS 89 }; 90 91 struct ath_pktlog_info { 92 struct ath_pktlog_buf *buf; 93 uint32_t log_state; 94 uint32_t saved_state; 95 uint32_t options; 96 /* Initial saved state: It will save the log state in pktlog 97 * open and used in pktlog release after 98 * pktlog read is complete. 99 */ 100 uint32_t init_saved_state; 101 enum ath_pktlog_state curr_pkt_state; 102 103 /* Size of buffer in bytes */ 104 int32_t buf_size; 105 qdf_spinlock_t log_lock; 106 struct mutex pktlog_mutex; 107 108 /* Threshold of TCP SACK packets for triggered stop */ 109 int sack_thr; 110 111 /* # of tail packets to log after triggered stop */ 112 int tail_length; 113 114 /* throuput threshold in bytes for triggered stop */ 115 uint32_t thruput_thresh; 116 117 /* (aggregated or single) packet size in bytes */ 118 uint32_t pktlen; 119 120 /* a temporary variable for counting TX throughput only */ 121 /* PER threshold for triggered stop, 10 for 10%, range [1, 99] */ 122 uint32_t per_thresh; 123 124 /* Phyerr threshold for triggered stop */ 125 uint32_t phyerr_thresh; 126 127 /* time period for counting trigger parameters, in milisecond */ 128 uint32_t trigger_interval; 129 uint32_t start_time_thruput; 130 uint32_t start_time_per; 131 }; 132 #endif /* _PKTLOG_INFO */ 133 #else /* REMOVE_PKT_LOG */ 134 typedef void *pktlog_dev_handle; 135 #define pktlog_set_pdev_id(pl_dev, pdev_id) \ 136 do { \ 137 (void)pl_dev; \ 138 (void)pdev_id; \ 139 } while (0) 140 141 #define pktlog_sethandle(pl_handle, scn) \ 142 do { \ 143 (void)pl_handle; \ 144 (void)scn; \ 145 } while (0) 146 147 #define ol_pl_set_name(dev) \ 148 do { \ 149 (void)scn; \ 150 (void)dev; \ 151 } while (0) 152 153 #endif /* REMOVE_PKT_LOG */ 154 #endif /* _PKTLOG_AC_API_ */ 155