Merge commit '06307114472bd8aad5ff18ccdb8e25f128ae6652'
[unleashed.git] / kernel / drivers / net / ixgbe / ixgbe_osdep.c
blobfcb695abfdbc464672205bcf34e430edb89513bc
1 /*
2 * CDDL HEADER START
4 * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at:
10 * http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When using or redistributing this file, you may do so under the
15 * License only. No other modification of this header is permitted.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
21 * CDDL HEADER END
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 * Copyright (c) 2017, Joyent, Inc.
30 #include "ixgbe_sw.h"
32 uint16_t
33 ixgbe_read_pci_cfg(struct ixgbe_hw *hw, uint32_t reg)
35 return (pci_config_get16(OS_DEP(hw)->cfg_handle, reg));
38 void
39 ixgbe_write_pci_cfg(struct ixgbe_hw *hw, uint32_t reg, uint32_t val)
41 pci_config_put16(OS_DEP(hw)->cfg_handle, reg, val);
45 * This is our last line of defense against a hardware device that has decided
46 * to somehow disappear without our knowledge of it. To try and deal with this,
47 * we'll read the status register and see if it returns all 1s, indicating an
48 * invalid read. Note the status register is defined to have bits in all current
49 * revisions that are hardwired to zero.
51 boolean_t
52 ixgbe_removed(struct ixgbe_hw *hw)
54 uint32_t val;
56 val = IXGBE_READ_REG(hw, IXGBE_STATUS);
57 if (val == PCI_EINVAL32) {
58 ixgbe_t *ixgbe = OS_DEP(hw)->ixgbe;
60 ixgbe_error(ixgbe, "failed to read status register: device "
61 "may be gone");
62 if (ixgbe->ixgbe_ks != NULL) {
63 ixgbe_stat_t *s = ixgbe->ixgbe_ks->ks_data;
64 s->dev_gone.value.ui64++;
66 return (B_TRUE);
68 return (B_FALSE);