1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * This file is part of the Chelsio T4 Ethernet driver. 14 * 15 * Copyright (C) 2005-2013 Chelsio Communications. All rights reserved. 16 * 17 * This program is distributed in the hope that it will be useful, but WITHOUT 18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 * FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file included in this 20 * release for licensing terms and conditions. 21 */ 22 23 #include "common.h" 24 25 int 26 is_offload(const struct adapter *adap) 27 { 28 return (adap->params.offload); 29 } 30 31 unsigned int 32 core_ticks_per_usec(const struct adapter *adap) 33 { 34 return (adap->params.vpd.cclk / 1000); 35 } 36 37 int 38 t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd, int size, void *rpl) 39 { 40 return (t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true)); 41 } 42 43 unsigned int 44 us_to_core_ticks(const struct adapter *adap, unsigned int us) 45 { 46 return ((us * adap->params.vpd.cclk) / 1000); 47 } 48 49 unsigned int 50 core_ticks_to_us(const struct adapter *adapter, unsigned int ticks) 51 { 52 /* add Core Clock / 2 to round ticks to nearest uS */ 53 return ((ticks * 1000 + adapter->params.vpd.cclk/2) / 54 adapter->params.vpd.cclk); 55 } 56 57 unsigned int 58 dack_ticks_to_usec(const struct adapter *adap, unsigned int ticks) 59 { 60 return ((ticks << adap->params.tp.dack_re) / core_ticks_per_usec(adap)); 61 } 62 63 int 64 is_bypass(const adapter_t *adap) 65 { 66 return (adap->params.bypass); 67 } 68 69 int is_t4(enum chip_type chip) 70 { 71 return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4); 72 } 73 74 int is_t5(enum chip_type chip) 75 { 76 return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5); 77 } 78 79 int is_fpga(enum chip_type chip) 80 { 81 return chip & CHELSIO_CHIP_FPGA; 82 } 83 84 int 85 is_bypass_device(int device) 86 { 87 /* TODO - this should be set based upon device capabilities */ 88 switch (device) { 89 #ifdef CONFIG_CHELSIO_BYPASS 90 case 0x440b: 91 case 0x440c: 92 return (1); 93 #endif 94 95 default: 96 return (0); 97 } 98 } 99 100 int 101 t4_wait_op_done(struct adapter *adapter, int reg, u32 mask, int polarity, 102 int attempts, int delay) 103 { 104 return (t4_wait_op_done_val(adapter, reg, mask, polarity, attempts, 105 delay, NULL)); 106 } 107 108 int 109 t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd, int size, 110 void *rpl) 111 { 112 return (t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false)); 113 } 114