1 /** 2 * aQuantia Corporation Network Driver 3 * Copyright (C) 2014-2017 aQuantia Corporation. 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 7 * are met: 8 * 9 * (1) Redistributions of source code must retain the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer. 12 * 13 * (2) Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * (3) The name of the author may not be used to endorse or promote 19 * products derived from this software without specific prior 20 * written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 23 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 28 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * @file aq_dbg.c 35 * Debugging stuff. 36 * @date 2017.12.13 @author roman.agafonov@aquantia.com 37 */ 38 39 40 #include <sys/param.h> 41 #include "aq_common.h" 42 #include "aq_dbg.h" 43 44 45 #define DESCR_FIELD(DESCR, BIT_BEGIN, BIT_END) \ 46 ((DESCR >> BIT_END) &\ 47 (BIT(BIT_BEGIN - BIT_END + 1) -1)) 48 49 #define __field(TYPE, VAR) TYPE VAR; 50 51 #if AQ_CFG_DEBUG_LVL > 2 52 void 53 trace_aq_tx_descr(struct aq_hw *hw, int ring_idx, unsigned int pointer, 54 volatile uint64_t descr[2]) 55 { 56 #if AQ_CFG_DEBUG_LVL > 2 57 struct __entry{ 58 __field(unsigned int, ring_idx) 59 __field(unsigned int, pointer) 60 /* Tx Descriptor */ 61 __field(uint64_t, data_buf_addr) 62 __field(uint32_t, pay_len) 63 __field(uint8_t, ct_en) 64 __field(uint8_t, ct_idx) 65 __field(uint16_t, rsvd2) 66 __field(uint8_t, tx_cmd) 67 __field(uint8_t, eop) 68 __field(uint8_t, dd) 69 __field(uint16_t, buf_len) 70 __field(uint8_t, rsvd1) 71 __field(uint8_t, des_typ) 72 } entry; 73 74 entry.ring_idx = ring_idx; 75 entry.pointer = pointer; 76 entry.data_buf_addr = descr[0]; 77 entry.pay_len = DESCR_FIELD(descr[1], 63, 46); 78 entry.ct_en = DESCR_FIELD(descr[1], 45, 45); 79 entry.ct_idx = DESCR_FIELD(descr[1], 44, 44); 80 entry.rsvd2 = DESCR_FIELD(descr[1], 43, 30); 81 entry.tx_cmd = DESCR_FIELD(descr[1], 29, 22); 82 entry.eop = DESCR_FIELD(descr[1], 21, 21); 83 entry.dd = DESCR_FIELD(descr[1], 20, 20); 84 entry.buf_len = DESCR_FIELD(descr[1], 19, 4); 85 entry.rsvd1 = DESCR_FIELD(descr[1], 3, 3); 86 entry.des_typ = DESCR_FIELD(descr[1], 2, 0); 87 88 89 aq_log_detail(hw, "trace_aq_tx_descr ring=%d descr=%u pay_len=%u ct_en=%u ct_idx=%u rsvd2=0x%x tx_cmd=0x%x eop=%u dd=%u buf_len=%u rsvd1=%u des_typ=0x%x", 90 entry.ring_idx, entry.pointer, entry.pay_len, 91 entry.ct_en, entry.ct_idx, entry.rsvd2, 92 entry.tx_cmd, entry.eop, entry.dd, entry.buf_len, 93 entry.rsvd1, entry.des_typ); 94 #endif 95 } 96 97 void 98 trace_aq_rx_descr(struct aq_hw *hw, int ring_idx, unsigned int pointer, 99 volatile uint64_t descr[2]) 100 { 101 #if AQ_CFG_DEBUG_LVL > 2 102 uint8_t dd; 103 uint8_t eop; 104 uint8_t rx_stat; 105 uint8_t rx_estat; 106 uint8_t rsc_cnt; 107 uint16_t pkt_len; 108 uint16_t next_desp; 109 uint16_t vlan_tag; 110 111 uint8_t rss_type; 112 uint8_t pkt_type; 113 uint8_t rdm_err; 114 uint8_t avb_ts; 115 uint8_t rsvd; 116 uint8_t rx_cntl; 117 uint8_t sph; 118 uint16_t hdr_len; 119 uint32_t rss_hash; 120 121 rss_hash = DESCR_FIELD(descr[0], 63, 32); 122 hdr_len = DESCR_FIELD(descr[0], 31, 22); 123 sph = DESCR_FIELD(descr[0], 21, 21); 124 rx_cntl = DESCR_FIELD(descr[0], 20, 19); 125 rsvd = DESCR_FIELD(descr[0], 18, 14); 126 avb_ts = DESCR_FIELD(descr[0], 13, 13); 127 rdm_err = DESCR_FIELD(descr[0], 12, 12); 128 pkt_type = DESCR_FIELD(descr[0], 11, 4); 129 rss_type = DESCR_FIELD(descr[0], 3, 0); 130 131 vlan_tag = DESCR_FIELD(descr[1], 63, 48); 132 next_desp = DESCR_FIELD(descr[1], 47, 32); 133 pkt_len = DESCR_FIELD(descr[1], 31, 16); 134 rsc_cnt = DESCR_FIELD(descr[1], 15, 12); 135 rx_estat = DESCR_FIELD(descr[1], 11, 6); 136 rx_stat = DESCR_FIELD(descr[1], 5, 2); 137 eop = DESCR_FIELD(descr[1], 1, 1); 138 dd = DESCR_FIELD(descr[1], 0, 0); 139 140 aq_log_detail(hw, "trace_aq_rx_descr ring=%d descr=%u rss_hash=0x%x hdr_len=%u sph=%u rx_cntl=%u rsvd=0x%x avb_ts=%u rdm_err=%u pkt_type=%u rss_type=%u vlan_tag=%u next_desp=%u pkt_len=%u rsc_cnt=%u rx_estat=0x%x rx_stat=0x%x eop=%u dd=%u", 141 ring_idx, pointer, rss_hash, 142 hdr_len, sph, rx_cntl, 143 rsvd, avb_ts, rdm_err, 144 pkt_type, rss_type, vlan_tag, 145 next_desp, pkt_len, rsc_cnt, 146 rx_estat, rx_stat, eop, dd); 147 #endif 148 } 149 150 void 151 trace_aq_tx_context_descr(struct aq_hw *hw, int ring_idx, unsigned int pointer, 152 volatile uint64_t descr[2]) 153 { 154 #if AQ_CFG_DEBUG_LVL > 2 155 struct __entry_s{ 156 __field(unsigned int, ring_idx) 157 __field(unsigned int, pointer) 158 /* Tx Context Descriptor */ 159 __field(uint16_t, out_len) 160 __field(uint8_t, tun_len) 161 __field(uint64_t, resvd3) 162 __field(uint16_t, mss_len) 163 __field(uint8_t, l4_len) 164 __field(uint8_t, l3_len) 165 __field(uint8_t, l2_len) 166 __field(uint8_t, ct_cmd) 167 __field(uint16_t, vlan_tag) 168 __field(uint8_t, ct_idx) 169 __field(uint8_t, des_typ) 170 } entry; 171 struct __entry_s *__entry = &entry; 172 __entry->ring_idx = ring_idx; 173 __entry->pointer = pointer; 174 __entry->out_len = DESCR_FIELD(descr[0], 63, 48); 175 __entry->tun_len = DESCR_FIELD(descr[0], 47, 40); 176 __entry->resvd3 = DESCR_FIELD(descr[0], 39, 0); 177 __entry->mss_len = DESCR_FIELD(descr[1], 63, 48); 178 __entry->l4_len = DESCR_FIELD(descr[1], 47, 40); 179 __entry->l3_len = DESCR_FIELD(descr[1], 39, 31); 180 __entry->l2_len = DESCR_FIELD(descr[1], 30, 24); 181 __entry->ct_cmd = DESCR_FIELD(descr[1], 23, 20); 182 __entry->vlan_tag = DESCR_FIELD(descr[1], 19, 4); 183 __entry->ct_idx = DESCR_FIELD(descr[1], 3, 3); 184 __entry->des_typ = DESCR_FIELD(descr[1], 2, 0); 185 186 aq_log_detail(hw, "trace_aq_tx_context_descr ring=%d descr=%u out_len=%u tun_len=%u resvd3=%lu mss_len=%u l4_len=%u l3_len=%u l2_len=%d ct_cmd=%u vlan_tag=%u ct_idx=%u des_typ=0x%x", 187 __entry->ring_idx, __entry->pointer, __entry->out_len, 188 __entry->tun_len, __entry->resvd3, __entry->mss_len, 189 __entry->l4_len, __entry->l3_len, __entry->l2_len, 190 __entry->ct_cmd, __entry->vlan_tag, __entry->ct_idx, 191 __entry->des_typ); 192 #endif 193 } 194 #endif 195