emlxs_hba.c (8f23e9fa) emlxs_hba.c (a3170057)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at

--- 8 unchanged lines hidden (view full) ---

17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2004-2012 Emulex. All rights reserved.
24 * Use is subject to license terms.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at

--- 8 unchanged lines hidden (view full) ---

17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2004-2012 Emulex. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
26 * Copyright 2020 RackTop Systems, Inc.
25 */
26
27#define EMLXS_FW_TABLE_DEF
28#define EMLXS_MODEL_DEF
29
30#include <emlxs.h>
31
32/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */

--- 952 unchanged lines hidden (view full) ---

985 hi = 10;
986 }
987
988 if (vpd->link_speed & LMT_16GB_CAPABLE) {
989 (void) strlcat(cfg->help, ", 16=16Gb", EMLXS_CFG_HELP_SIZE);
990 hi = 16;
991 }
992
27 */
28
29#define EMLXS_FW_TABLE_DEF
30#define EMLXS_MODEL_DEF
31
32#include <emlxs.h>
33
34/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */

--- 952 unchanged lines hidden (view full) ---

987 hi = 10;
988 }
989
990 if (vpd->link_speed & LMT_16GB_CAPABLE) {
991 (void) strlcat(cfg->help, ", 16=16Gb", EMLXS_CFG_HELP_SIZE);
992 hi = 16;
993 }
994
995 if (vpd->link_speed & LMT_32GB_CAPABLE) {
996 (void) strlcat(cfg->help, ", 32=32Gb", EMLXS_CFG_HELP_SIZE);
997 hi = 32;
998 }
999
993 (void) strlcat(cfg->help, "]", EMLXS_CFG_HELP_SIZE);
994 cfg->hi = hi;
995
996 /* Now revalidate the current parameter setting */
997 cfg->current = emlxs_check_parm(hba, CFG_LINK_SPEED, cfg->current);
998
999 return;
1000

--- 932 unchanged lines hidden (view full) ---

1933
1934extern uint32_t
1935emlxs_init_adapter_info(emlxs_hba_t *hba)
1936{
1937 emlxs_port_t *port = &PPORT;
1938 uint32_t pci_id;
1939 uint32_t cache_line;
1940 uint32_t channels;
1000 (void) strlcat(cfg->help, "]", EMLXS_CFG_HELP_SIZE);
1001 cfg->hi = hi;
1002
1003 /* Now revalidate the current parameter setting */
1004 cfg->current = emlxs_check_parm(hba, CFG_LINK_SPEED, cfg->current);
1005
1006 return;
1007

--- 932 unchanged lines hidden (view full) ---

1940
1941extern uint32_t
1942emlxs_init_adapter_info(emlxs_hba_t *hba)
1943{
1944 emlxs_port_t *port = &PPORT;
1945 uint32_t pci_id;
1946 uint32_t cache_line;
1947 uint32_t channels;
1948 uint16_t vendor_id;
1941 uint16_t device_id;
1942 uint16_t ssdid;
1943 uint32_t i;
1944 uint32_t found = 0;
1945 int32_t *prop;
1946 uint32_t num_prop;
1947
1948 if (hba->bus_type == SBUS_FC) {
1949 if (hba->pci_acc_handle == NULL) {
1950 bcopy(&emlxs_sbus_model[0], &hba->model_info,
1951 sizeof (emlxs_model_t));
1952
1949 uint16_t device_id;
1950 uint16_t ssdid;
1951 uint32_t i;
1952 uint32_t found = 0;
1953 int32_t *prop;
1954 uint32_t num_prop;
1955
1956 if (hba->bus_type == SBUS_FC) {
1957 if (hba->pci_acc_handle == NULL) {
1958 bcopy(&emlxs_sbus_model[0], &hba->model_info,
1959 sizeof (emlxs_model_t));
1960
1961 hba->model_info.vendor_id = 0;
1953 hba->model_info.device_id = 0;
1954
1955 return (0);
1956 }
1957
1958 /* Read the PCI device id */
1959 pci_id =
1960 ddi_get32(hba->pci_acc_handle,
1961 (uint32_t *)(hba->pci_addr + PCI_VENDOR_ID_REGISTER));
1962 hba->model_info.device_id = 0;
1963
1964 return (0);
1965 }
1966
1967 /* Read the PCI device id */
1968 pci_id =
1969 ddi_get32(hba->pci_acc_handle,
1970 (uint32_t *)(hba->pci_addr + PCI_VENDOR_ID_REGISTER));
1971 vendor_id = (uint16_t)pci_id;
1962 device_id = (uint16_t)(pci_id >> 16);
1963
1964 /* Find matching adapter model */
1965 for (i = 1; i < EMLXS_SBUS_MODEL_COUNT; i++) {
1972 device_id = (uint16_t)(pci_id >> 16);
1973
1974 /* Find matching adapter model */
1975 for (i = 1; i < EMLXS_SBUS_MODEL_COUNT; i++) {
1966 if (emlxs_sbus_model[i].device_id == device_id) {
1976 if (emlxs_sbus_model[i].vendor_id == vendor_id &&
1977 emlxs_sbus_model[i].device_id == device_id) {
1967 bcopy(&emlxs_sbus_model[i], &hba->model_info,
1968 sizeof (emlxs_model_t));
1969 found = 1;
1970 break;
1971 }
1972 }
1973
1974 /* If not found then use the unknown model */
1975 if (!found) {
1976 bcopy(&emlxs_sbus_model[0], &hba->model_info,
1977 sizeof (emlxs_model_t));
1978
1978 bcopy(&emlxs_sbus_model[i], &hba->model_info,
1979 sizeof (emlxs_model_t));
1980 found = 1;
1981 break;
1982 }
1983 }
1984
1985 /* If not found then use the unknown model */
1986 if (!found) {
1987 bcopy(&emlxs_sbus_model[0], &hba->model_info,
1988 sizeof (emlxs_model_t));
1989
1990 hba->model_info.vendor_id = vendor_id;
1979 hba->model_info.device_id = device_id;
1980
1981 return (0);
1982 }
1983 } else { /* PCI model */
1984
1985 if (hba->pci_acc_handle == NULL) {
1986 bcopy(&emlxs_pci_model[0], &hba->model_info,
1987 sizeof (emlxs_model_t));
1988
1991 hba->model_info.device_id = device_id;
1992
1993 return (0);
1994 }
1995 } else { /* PCI model */
1996
1997 if (hba->pci_acc_handle == NULL) {
1998 bcopy(&emlxs_pci_model[0], &hba->model_info,
1999 sizeof (emlxs_model_t));
2000
2001 hba->model_info.vendor_id = 0;
1989 hba->model_info.device_id = 0;
1990
1991 return (0);
1992 }
1993
2002 hba->model_info.device_id = 0;
2003
2004 return (0);
2005 }
2006
1994 /* Read the PCI device id */
2007 /* Read the PCI vendor and device id */
2008 vendor_id =
2009 ddi_get16(hba->pci_acc_handle,
2010 (uint16_t *)(hba->pci_addr + PCI_VENDOR_ID_REGISTER));
2011
1995 device_id =
1996 ddi_get16(hba->pci_acc_handle,
1997 (uint16_t *)(hba->pci_addr + PCI_DEVICE_ID_REGISTER));
1998
1999 /* Read the PCI Subsystem id */
2000 ssdid =
2001 ddi_get16(hba->pci_acc_handle,
2002 (uint16_t *)(hba->pci_addr + PCI_SSDID_REGISTER));
2003
2004 if (ssdid == 0 || ssdid == 0xffff) {
2005 ssdid = device_id;
2006 }
2007
2008 /* Read the Cache Line reg */
2009 cache_line =
2010 ddi_get32(hba->pci_acc_handle,
2011 (uint32_t *)(hba->pci_addr + PCI_CACHE_LINE_REGISTER));
2012
2012 device_id =
2013 ddi_get16(hba->pci_acc_handle,
2014 (uint16_t *)(hba->pci_addr + PCI_DEVICE_ID_REGISTER));
2015
2016 /* Read the PCI Subsystem id */
2017 ssdid =
2018 ddi_get16(hba->pci_acc_handle,
2019 (uint16_t *)(hba->pci_addr + PCI_SSDID_REGISTER));
2020
2021 if (ssdid == 0 || ssdid == 0xffff) {
2022 ssdid = device_id;
2023 }
2024
2025 /* Read the Cache Line reg */
2026 cache_line =
2027 ddi_get32(hba->pci_acc_handle,
2028 (uint32_t *)(hba->pci_addr + PCI_CACHE_LINE_REGISTER));
2029
2030 EMLXS_MSGF(EMLXS_CONTEXT,
2031 &emlxs_init_debug_msg, "Device IDs: %x/%x/%x/%x",
2032 vendor_id, device_id, ssdid, cache_line);
2033
2013 /* Check for the multifunction bit being set */
2014 if ((cache_line & 0x00ff0000) == 0x00800000) {
2015 channels = EMLXS_MULTI_CHANNEL;
2016 } else {
2017 channels = EMLXS_SINGLE_CHANNEL;
2018 }
2019
2020 /* If device ids are unique, then use them for search */
2021 if (device_id != ssdid) {
2022 /*
2023 * Find matching adapter model using
2034 /* Check for the multifunction bit being set */
2035 if ((cache_line & 0x00ff0000) == 0x00800000) {
2036 channels = EMLXS_MULTI_CHANNEL;
2037 } else {
2038 channels = EMLXS_SINGLE_CHANNEL;
2039 }
2040
2041 /* If device ids are unique, then use them for search */
2042 if (device_id != ssdid) {
2043 /*
2044 * Find matching adapter model using
2024 * device_id, ssdid, and channels
2045 * vendor_id, device_id, ssdid, and channels
2025 */
2026 for (i = 1; i < emlxs_pci_model_count; i++) {
2046 */
2047 for (i = 1; i < emlxs_pci_model_count; i++) {
2027 if (emlxs_pci_model[i].device_id ==
2028 device_id &&
2048 if (emlxs_pci_model[i].vendor_id == vendor_id &&
2049 emlxs_pci_model[i].device_id == device_id &&
2029 emlxs_pci_model[i].ssdid == ssdid &&
2030 emlxs_pci_model[i].channels ==
2031 channels) {
2032 bcopy(&emlxs_pci_model[i],
2033 &hba->model_info,
2034 sizeof (emlxs_model_t));
2035 found = 1;
2036 break;
2037 }
2038 }
2039 }
2040
2041 /* If adapter not found, try again */
2042 if (!found) {
2043 /*
2044 * Find matching adapter model using
2050 emlxs_pci_model[i].ssdid == ssdid &&
2051 emlxs_pci_model[i].channels ==
2052 channels) {
2053 bcopy(&emlxs_pci_model[i],
2054 &hba->model_info,
2055 sizeof (emlxs_model_t));
2056 found = 1;
2057 break;
2058 }
2059 }
2060 }
2061
2062 /* If adapter not found, try again */
2063 if (!found) {
2064 /*
2065 * Find matching adapter model using
2045 * device_id and channels
2066 * vendor_id, device_id and channels
2046 */
2047 for (i = 1; i < emlxs_pci_model_count; i++) {
2067 */
2068 for (i = 1; i < emlxs_pci_model_count; i++) {
2048 if (emlxs_pci_model[i].device_id == device_id &&
2069 if (emlxs_pci_model[i].vendor_id == vendor_id &&
2070 emlxs_pci_model[i].device_id == device_id &&
2049 emlxs_pci_model[i].channels == channels) {
2050 bcopy(&emlxs_pci_model[i],
2051 &hba->model_info,
2052 sizeof (emlxs_model_t));
2053 found = 1;
2054 break;
2055 }
2056 }
2057 }
2058
2059 /* If adapter not found, try one last time */
2060 if (!found) {
2061 /*
2062 * Find matching adapter model using
2071 emlxs_pci_model[i].channels == channels) {
2072 bcopy(&emlxs_pci_model[i],
2073 &hba->model_info,
2074 sizeof (emlxs_model_t));
2075 found = 1;
2076 break;
2077 }
2078 }
2079 }
2080
2081 /* If adapter not found, try one last time */
2082 if (!found) {
2083 /*
2084 * Find matching adapter model using
2063 * device_id only
2085 * vendor_id and device_id only
2064 */
2065 for (i = 1; i < emlxs_pci_model_count; i++) {
2086 */
2087 for (i = 1; i < emlxs_pci_model_count; i++) {
2066 if (emlxs_pci_model[i].device_id == device_id) {
2088 if (emlxs_pci_model[i].vendor_id == vendor_id &&
2089 emlxs_pci_model[i].device_id == device_id) {
2067 bcopy(&emlxs_pci_model[i],
2068 &hba->model_info,
2069 sizeof (emlxs_model_t));
2070 found = 1;
2071 break;
2072 }
2073 }
2074 }
2075
2076 /* If not found, set adapter to unknown */
2077 if (!found) {
2078 bcopy(&emlxs_pci_model[0], &hba->model_info,
2079 sizeof (emlxs_model_t));
2080
2090 bcopy(&emlxs_pci_model[i],
2091 &hba->model_info,
2092 sizeof (emlxs_model_t));
2093 found = 1;
2094 break;
2095 }
2096 }
2097 }
2098
2099 /* If not found, set adapter to unknown */
2100 if (!found) {
2101 bcopy(&emlxs_pci_model[0], &hba->model_info,
2102 sizeof (emlxs_model_t));
2103
2104 hba->model_info.vendor_id = vendor_id;
2081 hba->model_info.device_id = device_id;
2082 hba->model_info.ssdid = ssdid;
2083
2084 return (0);
2085 }
2086
2087#ifndef SATURN_MSI_SUPPORT
2088 /*

--- 977 unchanged lines hidden ---
2105 hba->model_info.device_id = device_id;
2106 hba->model_info.ssdid = ssdid;
2107
2108 return (0);
2109 }
2110
2111#ifndef SATURN_MSI_SUPPORT
2112 /*

--- 977 unchanged lines hidden ---