comparison usr/src/uts/common/io/cxgbe/common/common.c @ 14029:11aad50aea32

3701 Chelsio Terminator 4 NIC driver for illumos Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Dan McDonald <danmcd@nexenta.com>
author Gireesh Nagabhushana <gireesh@chelsio.com>
date Thu, 23 May 2013 09:51:05 -0400
parents
children
comparison
equal deleted inserted replaced
14028:bcbb822da4dd 14029:11aad50aea32
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
70 is_bypass_device(int device)
71 {
72 /* TODO - this should be set based upon device capabilities */
73 switch (device) {
74 #ifdef CONFIG_CHELSIO_BYPASS
75 case 0x440b:
76 case 0x440c:
77 return (1);
78 #endif
79
80 default:
81 return (0);
82 }
83 }
84
85 int
86 t4_wait_op_done(struct adapter *adapter, int reg, u32 mask, int polarity,
87 int attempts, int delay)
88 {
89 return (t4_wait_op_done_val(adapter, reg, mask, polarity, attempts,
90 delay, NULL));
91 }
92
93 int
94 t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd, int size,
95 void *rpl)
96 {
97 return (t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false));
98 }