1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
|
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2019-2021 Xilinx, Inc.
* Copyright(c) 2018-2019 Solarflare Communications Inc.
*/
#include "efx.h"
#include "efx_impl.h"
#if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
#if EFSYS_OPT_SIENA
static const efx_proxy_ops_t __efx_proxy_dummy_ops = {
NULL, /* epo_init */
NULL, /* epo_fini */
NULL, /* epo_mc_config */
NULL, /* epo_disable */
NULL, /* epo_privilege_modify */
NULL, /* epo_set_privilege_mask */
NULL, /* epo_complete_request */
NULL, /* epo_exec_cmd */
NULL, /* epo_get_privilege_mask */
};
#endif /* EFSYS_OPT_SIENA */
#if EFX_OPTS_EF10()
static const efx_proxy_ops_t __efx_proxy_ef10_ops = {
ef10_proxy_auth_init, /* epo_init */
ef10_proxy_auth_fini, /* epo_fini */
ef10_proxy_auth_mc_config, /* epo_mc_config */
ef10_proxy_auth_disable, /* epo_disable */
ef10_proxy_auth_privilege_modify, /* epo_privilege_modify */
ef10_proxy_auth_set_privilege_mask, /* epo_set_privilege_mask */
ef10_proxy_auth_complete_request, /* epo_complete_request */
ef10_proxy_auth_exec_cmd, /* epo_exec_cmd */
ef10_proxy_auth_get_privilege_mask, /* epo_get_privilege_mask */
};
#endif /* EFX_OPTS_EF10() */
__checkReturn efx_rc_t
efx_proxy_auth_init(
__in efx_nic_t *enp)
{
const efx_proxy_ops_t *epop;
efx_rc_t rc;
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_PROXY));
switch (enp->en_family) {
#if EFSYS_OPT_SIENA
case EFX_FAMILY_SIENA:
epop = &__efx_proxy_dummy_ops;
break;
#endif /* EFSYS_OPT_SIENA */
#if EFSYS_OPT_HUNTINGTON
case EFX_FAMILY_HUNTINGTON:
epop = &__efx_proxy_ef10_ops;
break;
#endif /* EFSYS_OPT_HUNTINGTON */
#if EFSYS_OPT_MEDFORD
case EFX_FAMILY_MEDFORD:
epop = &__efx_proxy_ef10_ops;
break;
#endif /* EFSYS_OPT_MEDFORD */
#if EFSYS_OPT_MEDFORD2
case EFX_FAMILY_MEDFORD2:
epop = &__efx_proxy_ef10_ops;
break;
#endif /* EFSYS_OPT_MEDFORD2 */
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
goto fail1;
}
if (epop->epo_init == NULL) {
rc = ENOTSUP;
goto fail2;
}
if ((rc = epop->epo_init(enp)) != 0)
goto fail3;
enp->en_epop = epop;
enp->en_mod_flags |= EFX_MOD_PROXY;
return (0);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
void
efx_proxy_auth_fini(
__in efx_nic_t *enp)
{
const efx_proxy_ops_t *epop = enp->en_epop;
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROBE);
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if ((epop != NULL) && (epop->epo_fini != NULL))
epop->epo_fini(enp);
enp->en_epop = NULL;
enp->en_mod_flags &= ~EFX_MOD_PROXY;
}
__checkReturn efx_rc_t
efx_proxy_auth_configure(
__in efx_nic_t *enp,
__in efx_proxy_auth_config_t *configp)
{
const efx_proxy_ops_t *epop = enp->en_epop;
efx_rc_t rc;
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if ((configp == NULL) ||
(configp->request_bufferp == NULL) ||
(configp->response_bufferp == NULL) ||
(configp->status_bufferp == NULL) ||
(configp->op_listp == NULL) ||
(configp->block_cnt == 0)) {
rc = EINVAL;
goto fail1;
}
if ((epop->epo_mc_config == NULL) ||
(epop->epo_privilege_modify == NULL)) {
rc = ENOTSUP;
goto fail2;
}
rc = epop->epo_mc_config(enp, configp->request_bufferp,
configp->response_bufferp, configp->status_bufferp,
configp->block_cnt, configp->op_listp,
configp->op_count);
if (rc != 0)
goto fail3;
rc = epop->epo_privilege_modify(enp, MC_CMD_PRIVILEGE_MODIFY_IN_ALL,
0, 0, 0, configp->handled_privileges);
if (rc != 0)
goto fail4;
return (0);
fail4:
EFSYS_PROBE(fail4);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
efx_proxy_auth_destroy(
__in efx_nic_t *enp,
__in uint32_t handled_privileges)
{
const efx_proxy_ops_t *epop = enp->en_epop;
efx_rc_t rc;
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if ((epop->epo_disable == NULL) ||
(epop->epo_privilege_modify == NULL)) {
rc = ENOTSUP;
goto fail1;
}
rc = epop->epo_privilege_modify(enp, MC_CMD_PRIVILEGE_MODIFY_IN_ALL,
0, 0, handled_privileges, 0);
if (rc != 0)
goto fail2;
rc = epop->epo_disable(enp);
if (rc != 0)
goto fail3;
return (0);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
efx_proxy_auth_complete_request(
__in efx_nic_t *enp,
__in uint32_t fn_index,
__in uint32_t proxy_result,
__in uint32_t handle)
{
const efx_proxy_ops_t *epop = enp->en_epop;
efx_rc_t rc;
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if (epop->epo_complete_request == NULL) {
rc = ENOTSUP;
goto fail1;
}
rc = epop->epo_complete_request(enp, fn_index, proxy_result, handle);
if (rc != 0)
goto fail2;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
efx_proxy_auth_exec_cmd(
__in efx_nic_t *enp,
__inout efx_proxy_cmd_params_t *paramsp)
{
const efx_proxy_ops_t *epop = enp->en_epop;
efx_rc_t rc;
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if (paramsp == NULL) {
rc = EINVAL;
goto fail1;
}
if (epop->epo_exec_cmd == NULL) {
rc = ENOTSUP;
goto fail2;
}
rc = epop->epo_exec_cmd(enp, paramsp);
if (rc != 0)
goto fail3;
return (0);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
efx_proxy_auth_set_privilege_mask(
__in efx_nic_t *enp,
__in uint32_t vf_index,
__in uint32_t mask,
__in uint32_t value)
{
const efx_proxy_ops_t *epop = enp->en_epop;
efx_rc_t rc;
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if (epop->epo_set_privilege_mask == NULL) {
rc = ENOTSUP;
goto fail1;
}
rc = epop->epo_set_privilege_mask(enp, vf_index, mask, value);
if (rc != 0)
goto fail2;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
efx_proxy_auth_privilege_mask_get(
__in efx_nic_t *enp,
__in uint32_t pf_index,
__in uint32_t vf_index,
__out uint32_t *maskp)
{
const efx_proxy_ops_t *epop = enp->en_epop;
efx_rc_t rc;
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if (epop->epo_get_privilege_mask == NULL) {
rc = ENOTSUP;
goto fail1;
}
rc = epop->epo_get_privilege_mask(enp, pf_index, vf_index, maskp);
if (rc != 0)
goto fail2;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
efx_proxy_auth_privilege_modify(
__in efx_nic_t *enp,
__in uint32_t pf_index,
__in uint32_t vf_index,
__in uint32_t add_privileges_mask,
__in uint32_t remove_privileges_mask)
{
const efx_proxy_ops_t *epop = enp->en_epop;
efx_rc_t rc;
EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROXY);
if (epop->epo_privilege_modify == NULL) {
rc = ENOTSUP;
goto fail1;
}
rc = epop->epo_privilege_modify(enp, MC_CMD_PRIVILEGE_MODIFY_IN_ONE,
pf_index, vf_index, add_privileges_mask,
remove_privileges_mask);
if (rc != 0)
goto fail2;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
#endif /* EFSYS_OPT_MCDI_PROXY_AUTH_SERVER */
|