Deleted Added
full compact
ef10_nic.c (299719) ef10_nic.c (299904)
1/*-
2 * Copyright (c) 2012-2015 Solarflare Communications Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,

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

24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2012-2015 Solarflare Communications Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,

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

24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/sfxge/common/ef10_nic.c 299719 2016-05-14 06:00:00Z arybchik $");
32__FBSDID("$FreeBSD: head/sys/dev/sfxge/common/ef10_nic.c 299904 2016-05-16 06:38:51Z arybchik $");
33
34#include "efx.h"
35#include "efx_impl.h"
36#if EFSYS_OPT_MON_MCDI
37#include "mcdi_mon.h"
38#endif
39
40#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD

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

83 EFSYS_PROBE1(fail1, efx_rc_t, rc);
84
85 return (rc);
86}
87
88 __checkReturn efx_rc_t
89efx_mcdi_get_port_modes(
90 __in efx_nic_t *enp,
33
34#include "efx.h"
35#include "efx_impl.h"
36#if EFSYS_OPT_MON_MCDI
37#include "mcdi_mon.h"
38#endif
39
40#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD

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

83 EFSYS_PROBE1(fail1, efx_rc_t, rc);
84
85 return (rc);
86}
87
88 __checkReturn efx_rc_t
89efx_mcdi_get_port_modes(
90 __in efx_nic_t *enp,
91 __out uint32_t *modesp)
91 __out uint32_t *modesp,
92 __out_opt uint32_t *current_modep)
92{
93 efx_mcdi_req_t req;
94 uint8_t payload[MAX(MC_CMD_GET_PORT_MODES_IN_LEN,
95 MC_CMD_GET_PORT_MODES_OUT_LEN)];
96 efx_rc_t rc;
97
98 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
99 enp->en_family == EFX_FAMILY_MEDFORD);

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

108 efx_mcdi_execute(enp, &req);
109
110 if (req.emr_rc != 0) {
111 rc = req.emr_rc;
112 goto fail1;
113 }
114
115 /*
93{
94 efx_mcdi_req_t req;
95 uint8_t payload[MAX(MC_CMD_GET_PORT_MODES_IN_LEN,
96 MC_CMD_GET_PORT_MODES_OUT_LEN)];
97 efx_rc_t rc;
98
99 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
100 enp->en_family == EFX_FAMILY_MEDFORD);

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

109 efx_mcdi_execute(enp, &req);
110
111 if (req.emr_rc != 0) {
112 rc = req.emr_rc;
113 goto fail1;
114 }
115
116 /*
116 * Require only Modes and DefaultMode fields.
117 * (CurrentMode field was added for Medford)
117 * Require only Modes and DefaultMode fields, unless the current mode
118 * was requested (CurrentMode field was added for Medford).
118 */
119 if (req.emr_out_length_used <
120 MC_CMD_GET_PORT_MODES_OUT_CURRENT_MODE_OFST) {
121 rc = EMSGSIZE;
122 goto fail2;
123 }
119 */
120 if (req.emr_out_length_used <
121 MC_CMD_GET_PORT_MODES_OUT_CURRENT_MODE_OFST) {
122 rc = EMSGSIZE;
123 goto fail2;
124 }
125 if ((current_modep != NULL) && (req.emr_out_length_used <
126 MC_CMD_GET_PORT_MODES_OUT_CURRENT_MODE_OFST + 4)) {
127 rc = EMSGSIZE;
128 goto fail3;
129 }
124
125 *modesp = MCDI_OUT_DWORD(req, GET_PORT_MODES_OUT_MODES);
126
130
131 *modesp = MCDI_OUT_DWORD(req, GET_PORT_MODES_OUT_MODES);
132
133 if (current_modep != NULL) {
134 *current_modep = MCDI_OUT_DWORD(req,
135 GET_PORT_MODES_OUT_CURRENT_MODE);
136 }
137
127 return (0);
128
138 return (0);
139
140fail3:
141 EFSYS_PROBE(fail3);
129fail2:
130 EFSYS_PROBE(fail2);
131fail1:
132 EFSYS_PROBE1(fail1, efx_rc_t, rc);
133
134 return (rc);
135}
136
142fail2:
143 EFSYS_PROBE(fail2);
144fail1:
145 EFSYS_PROBE1(fail1, efx_rc_t, rc);
146
147 return (rc);
148}
149
150 __checkReturn efx_rc_t
151ef10_nic_get_port_mode_bandwidth(
152 __in uint32_t port_mode,
153 __out uint32_t *bandwidth_mbpsp)
154{
155 uint32_t bandwidth;
156 efx_rc_t rc;
137
157
158 switch (port_mode) {
159 case TLV_PORT_MODE_10G:
160 bandwidth = 10000;
161 break;
162 case TLV_PORT_MODE_10G_10G:
163 bandwidth = 10000 * 2;
164 break;
165 case TLV_PORT_MODE_10G_10G_10G_10G:
166 case TLV_PORT_MODE_10G_10G_10G_10G_Q:
167 case TLV_PORT_MODE_10G_10G_10G_10G_Q2:
168 bandwidth = 10000 * 4;
169 break;
170 case TLV_PORT_MODE_40G:
171 bandwidth = 40000;
172 break;
173 case TLV_PORT_MODE_40G_40G:
174 bandwidth = 40000 * 2;
175 break;
176 case TLV_PORT_MODE_40G_10G_10G:
177 case TLV_PORT_MODE_10G_10G_40G:
178 bandwidth = 40000 + (10000 * 2);
179 break;
180 default:
181 rc = EINVAL;
182 goto fail1;
183 }
184
185 *bandwidth_mbpsp = bandwidth;
186
187 return (0);
188
189fail1:
190 EFSYS_PROBE1(fail1, efx_rc_t, rc);
191
192 return (rc);
193}
194
138static __checkReturn efx_rc_t
139efx_mcdi_vadaptor_alloc(
140 __in efx_nic_t *enp,
141 __in uint32_t port_id)
142{
143 efx_mcdi_req_t req;
144 uint8_t payload[MAX(MC_CMD_VADAPTOR_ALLOC_IN_LEN,
145 MC_CMD_VADAPTOR_ALLOC_OUT_LEN)];

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

1085 __out uint8_t *external_portp)
1086{
1087 efx_rc_t rc;
1088 int i;
1089 uint32_t port_modes;
1090 uint32_t matches;
1091 uint32_t stride = 1; /* default 1-1 mapping */
1092
195static __checkReturn efx_rc_t
196efx_mcdi_vadaptor_alloc(
197 __in efx_nic_t *enp,
198 __in uint32_t port_id)
199{
200 efx_mcdi_req_t req;
201 uint8_t payload[MAX(MC_CMD_VADAPTOR_ALLOC_IN_LEN,
202 MC_CMD_VADAPTOR_ALLOC_OUT_LEN)];

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

1142 __out uint8_t *external_portp)
1143{
1144 efx_rc_t rc;
1145 int i;
1146 uint32_t port_modes;
1147 uint32_t matches;
1148 uint32_t stride = 1; /* default 1-1 mapping */
1149
1093 if ((rc = efx_mcdi_get_port_modes(enp, &port_modes)) != 0) {
1150 if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, NULL)) != 0) {
1094 /* No port mode information available - use default mapping */
1095 goto out;
1096 }
1097
1098 /*
1099 * Infer the internal port -> external port mapping from
1100 * the possible port modes for this NIC.
1101 */

--- 531 unchanged lines hidden ---
1151 /* No port mode information available - use default mapping */
1152 goto out;
1153 }
1154
1155 /*
1156 * Infer the internal port -> external port mapping from
1157 * the possible port modes for this NIC.
1158 */

--- 531 unchanged lines hidden ---