| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_aq.c,v 1.17.2.2 2020/07/07 10:29:05 martin Exp $ */ | | 1 | /* $NetBSD: if_aq.c,v 1.17.2.3 2020/07/07 12:02:29 martin Exp $ */ |
2 | | | 2 | |
3 | /** | | 3 | /** |
4 | * aQuantia Corporation Network Driver | | 4 | * aQuantia Corporation Network Driver |
5 | * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved | | 5 | * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * | | 10 | * |
11 | * (1) Redistributions of source code must retain the above | | 11 | * (1) Redistributions of source code must retain the above |
12 | * copyright notice, this list of conditions and the following | | 12 | * copyright notice, this list of conditions and the following |
13 | * disclaimer. | | 13 | * disclaimer. |
14 | * | | 14 | * |
| @@ -52,27 +52,27 @@ | | | @@ -52,27 +52,27 @@ |
52 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | 52 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
53 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 53 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
54 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | | 54 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
55 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 55 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
56 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 56 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
57 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 57 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
59 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | | 59 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
60 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 60 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
61 | * POSSIBILITY OF SUCH DAMAGE. | | 61 | * POSSIBILITY OF SUCH DAMAGE. |
62 | */ | | 62 | */ |
63 | | | 63 | |
64 | #include <sys/cdefs.h> | | 64 | #include <sys/cdefs.h> |
65 | __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.17.2.2 2020/07/07 10:29:05 martin Exp $"); | | 65 | __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.17.2.3 2020/07/07 12:02:29 martin Exp $"); |
66 | | | 66 | |
67 | #ifdef _KERNEL_OPT | | 67 | #ifdef _KERNEL_OPT |
68 | #include "opt_if_aq.h" | | 68 | #include "opt_if_aq.h" |
69 | #include "sysmon_envsys.h" | | 69 | #include "sysmon_envsys.h" |
70 | #endif | | 70 | #endif |
71 | | | 71 | |
72 | #include <sys/param.h> | | 72 | #include <sys/param.h> |
73 | #include <sys/types.h> | | 73 | #include <sys/types.h> |
74 | #include <sys/bitops.h> | | 74 | #include <sys/bitops.h> |
75 | #include <sys/cprng.h> | | 75 | #include <sys/cprng.h> |
76 | #include <sys/cpu.h> | | 76 | #include <sys/cpu.h> |
77 | #include <sys/interrupt.h> | | 77 | #include <sys/interrupt.h> |
78 | #include <sys/module.h> | | 78 | #include <sys/module.h> |
| @@ -942,27 +942,27 @@ struct aq_firmware_ops { | | | @@ -942,27 +942,27 @@ struct aq_firmware_ops { |
942 | #define AQ_UNLOCK(sc) mutex_exit(&(sc)->sc_mutex); | | 942 | #define AQ_UNLOCK(sc) mutex_exit(&(sc)->sc_mutex); |
943 | | | 943 | |
944 | /* lock for FW2X_MPI_{CONTROL,STATE]_REG read-modify-write */ | | 944 | /* lock for FW2X_MPI_{CONTROL,STATE]_REG read-modify-write */ |
945 | #define AQ_MPI_LOCK(sc) mutex_enter(&(sc)->sc_mpi_mutex); | | 945 | #define AQ_MPI_LOCK(sc) mutex_enter(&(sc)->sc_mpi_mutex); |
946 | #define AQ_MPI_UNLOCK(sc) mutex_exit(&(sc)->sc_mpi_mutex); | | 946 | #define AQ_MPI_UNLOCK(sc) mutex_exit(&(sc)->sc_mpi_mutex); |
947 | | | 947 | |
948 | | | 948 | |
949 | struct aq_softc { | | 949 | struct aq_softc { |
950 | device_t sc_dev; | | 950 | device_t sc_dev; |
951 | | | 951 | |
952 | bus_space_tag_t sc_iot; | | 952 | bus_space_tag_t sc_iot; |
953 | bus_space_handle_t sc_ioh; | | 953 | bus_space_handle_t sc_ioh; |
954 | bus_size_t sc_iosize; | | 954 | bus_size_t sc_iosize; |
955 | bus_dma_tag_t sc_dmat;; | | 955 | bus_dma_tag_t sc_dmat; |
956 | | | 956 | |
957 | void *sc_ihs[AQ_NINTR_MAX]; | | 957 | void *sc_ihs[AQ_NINTR_MAX]; |
958 | pci_intr_handle_t *sc_intrs; | | 958 | pci_intr_handle_t *sc_intrs; |
959 | | | 959 | |
960 | int sc_tx_irq[AQ_RSSQUEUE_MAX]; | | 960 | int sc_tx_irq[AQ_RSSQUEUE_MAX]; |
961 | int sc_rx_irq[AQ_RSSQUEUE_MAX]; | | 961 | int sc_rx_irq[AQ_RSSQUEUE_MAX]; |
962 | int sc_linkstat_irq; | | 962 | int sc_linkstat_irq; |
963 | bool sc_use_txrx_independent_intr; | | 963 | bool sc_use_txrx_independent_intr; |
964 | bool sc_poll_linkstat; | | 964 | bool sc_poll_linkstat; |
965 | bool sc_detect_linkstat; | | 965 | bool sc_detect_linkstat; |
966 | | | 966 | |
967 | #if NSYSMON_ENVSYS > 0 | | 967 | #if NSYSMON_ENVSYS > 0 |
968 | struct sysmon_envsys *sc_sme; | | 968 | struct sysmon_envsys *sc_sme; |
| @@ -975,27 +975,27 @@ struct aq_softc { | | | @@ -975,27 +975,27 @@ struct aq_softc { |
975 | bool sc_msix; | | 975 | bool sc_msix; |
976 | | | 976 | |
977 | struct aq_queue sc_queue[AQ_RSSQUEUE_MAX]; | | 977 | struct aq_queue sc_queue[AQ_RSSQUEUE_MAX]; |
978 | int sc_nqueues; | | 978 | int sc_nqueues; |
979 | | | 979 | |
980 | pci_chipset_tag_t sc_pc; | | 980 | pci_chipset_tag_t sc_pc; |
981 | pcitag_t sc_pcitag; | | 981 | pcitag_t sc_pcitag; |
982 | uint16_t sc_product; | | 982 | uint16_t sc_product; |
983 | uint16_t sc_revision; | | 983 | uint16_t sc_revision; |
984 | | | 984 | |
985 | kmutex_t sc_mutex; | | 985 | kmutex_t sc_mutex; |
986 | kmutex_t sc_mpi_mutex; | | 986 | kmutex_t sc_mpi_mutex; |
987 | | | 987 | |
988 | struct aq_firmware_ops *sc_fw_ops; | | 988 | const struct aq_firmware_ops *sc_fw_ops; |
989 | uint64_t sc_fw_caps; | | 989 | uint64_t sc_fw_caps; |
990 | enum aq_media_type sc_media_type; | | 990 | enum aq_media_type sc_media_type; |
991 | aq_link_speed_t sc_available_rates; | | 991 | aq_link_speed_t sc_available_rates; |
992 | | | 992 | |
993 | aq_link_speed_t sc_link_rate; | | 993 | aq_link_speed_t sc_link_rate; |
994 | aq_link_fc_t sc_link_fc; | | 994 | aq_link_fc_t sc_link_fc; |
995 | aq_link_eee_t sc_link_eee; | | 995 | aq_link_eee_t sc_link_eee; |
996 | | | 996 | |
997 | uint32_t sc_fw_version; | | 997 | uint32_t sc_fw_version; |
998 | #define FW_VERSION_MAJOR(sc) (((sc)->sc_fw_version >> 24) & 0xff) | | 998 | #define FW_VERSION_MAJOR(sc) (((sc)->sc_fw_version >> 24) & 0xff) |
999 | #define FW_VERSION_MINOR(sc) (((sc)->sc_fw_version >> 16) & 0xff) | | 999 | #define FW_VERSION_MINOR(sc) (((sc)->sc_fw_version >> 16) & 0xff) |
1000 | #define FW_VERSION_BUILD(sc) ((sc)->sc_fw_version & 0xffff) | | 1000 | #define FW_VERSION_BUILD(sc) ((sc)->sc_fw_version & 0xffff) |
1001 | uint32_t sc_features; | | 1001 | uint32_t sc_features; |
| @@ -1114,37 +1114,37 @@ static int fw1x_get_mode(struct aq_softc | | | @@ -1114,37 +1114,37 @@ static int fw1x_get_mode(struct aq_softc |
1114 | aq_link_speed_t *, aq_link_fc_t *, aq_link_eee_t *); | | 1114 | aq_link_speed_t *, aq_link_fc_t *, aq_link_eee_t *); |
1115 | static int fw1x_get_stats(struct aq_softc *, aq_hw_stats_s_t *); | | 1115 | static int fw1x_get_stats(struct aq_softc *, aq_hw_stats_s_t *); |
1116 | | | 1116 | |
1117 | static int fw2x_reset(struct aq_softc *); | | 1117 | static int fw2x_reset(struct aq_softc *); |
1118 | static int fw2x_set_mode(struct aq_softc *, aq_hw_fw_mpi_state_t, | | 1118 | static int fw2x_set_mode(struct aq_softc *, aq_hw_fw_mpi_state_t, |
1119 | aq_link_speed_t, aq_link_fc_t, aq_link_eee_t); | | 1119 | aq_link_speed_t, aq_link_fc_t, aq_link_eee_t); |
1120 | static int fw2x_get_mode(struct aq_softc *, aq_hw_fw_mpi_state_t *, | | 1120 | static int fw2x_get_mode(struct aq_softc *, aq_hw_fw_mpi_state_t *, |
1121 | aq_link_speed_t *, aq_link_fc_t *, aq_link_eee_t *); | | 1121 | aq_link_speed_t *, aq_link_fc_t *, aq_link_eee_t *); |
1122 | static int fw2x_get_stats(struct aq_softc *, aq_hw_stats_s_t *); | | 1122 | static int fw2x_get_stats(struct aq_softc *, aq_hw_stats_s_t *); |
1123 | #if NSYSMON_ENVSYS > 0 | | 1123 | #if NSYSMON_ENVSYS > 0 |
1124 | static int fw2x_get_temperature(struct aq_softc *, uint32_t *); | | 1124 | static int fw2x_get_temperature(struct aq_softc *, uint32_t *); |
1125 | #endif | | 1125 | #endif |
1126 | | | 1126 | |
1127 | static struct aq_firmware_ops aq_fw1x_ops = { | | 1127 | static const struct aq_firmware_ops aq_fw1x_ops = { |
1128 | .reset = fw1x_reset, | | 1128 | .reset = fw1x_reset, |
1129 | .set_mode = fw1x_set_mode, | | 1129 | .set_mode = fw1x_set_mode, |
1130 | .get_mode = fw1x_get_mode, | | 1130 | .get_mode = fw1x_get_mode, |
1131 | .get_stats = fw1x_get_stats, | | 1131 | .get_stats = fw1x_get_stats, |
1132 | #if NSYSMON_ENVSYS > 0 | | 1132 | #if NSYSMON_ENVSYS > 0 |
1133 | .get_temperature = NULL | | 1133 | .get_temperature = NULL |
1134 | #endif | | 1134 | #endif |
1135 | }; | | 1135 | }; |
1136 | | | 1136 | |
1137 | static struct aq_firmware_ops aq_fw2x_ops = { | | 1137 | static const struct aq_firmware_ops aq_fw2x_ops = { |
1138 | .reset = fw2x_reset, | | 1138 | .reset = fw2x_reset, |
1139 | .set_mode = fw2x_set_mode, | | 1139 | .set_mode = fw2x_set_mode, |
1140 | .get_mode = fw2x_get_mode, | | 1140 | .get_mode = fw2x_get_mode, |
1141 | .get_stats = fw2x_get_stats, | | 1141 | .get_stats = fw2x_get_stats, |
1142 | #if NSYSMON_ENVSYS > 0 | | 1142 | #if NSYSMON_ENVSYS > 0 |
1143 | .get_temperature = fw2x_get_temperature | | 1143 | .get_temperature = fw2x_get_temperature |
1144 | #endif | | 1144 | #endif |
1145 | }; | | 1145 | }; |
1146 | | | 1146 | |
1147 | CFATTACH_DECL3_NEW(aq, sizeof(struct aq_softc), | | 1147 | CFATTACH_DECL3_NEW(aq, sizeof(struct aq_softc), |
1148 | aq_match, aq_attach, aq_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); | | 1148 | aq_match, aq_attach, aq_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); |
1149 | | | 1149 | |
1150 | static const struct aq_product { | | 1150 | static const struct aq_product { |