1 // SPDX-License-Identifier: GPL-2.0-only 2 /**************************************************************************** 3 * Driver for Solarflare network controllers and boards 4 * Copyright 2019 Solarflare Communications Inc. 5 * Copyright 2020-2022 Xilinx Inc. 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License version 2 as published 9 * by the Free Software Foundation, incorporated herein by reference. 10 */ 11 12 #include "mae.h" 13 #include "mcdi.h" 14 #include "mcdi_pcol.h" 15 16 void efx_mae_mport_vf(struct efx_nic *efx __always_unused, u32 vf_id, u32 *out) 17 { 18 efx_dword_t mport; 19 20 EFX_POPULATE_DWORD_3(mport, 21 MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_FUNC, 22 MAE_MPORT_SELECTOR_FUNC_PF_ID, MAE_MPORT_SELECTOR_FUNC_PF_ID_CALLER, 23 MAE_MPORT_SELECTOR_FUNC_VF_ID, vf_id); 24 *out = EFX_DWORD_VAL(mport); 25 } 26 27 /* id is really only 24 bits wide */ 28 int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id) 29 { 30 MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_MPORT_LOOKUP_OUT_LEN); 31 MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_MPORT_LOOKUP_IN_LEN); 32 size_t outlen; 33 int rc; 34 35 MCDI_SET_DWORD(inbuf, MAE_MPORT_LOOKUP_IN_MPORT_SELECTOR, selector); 36 rc = efx_mcdi_rpc(efx, MC_CMD_MAE_MPORT_LOOKUP, inbuf, sizeof(inbuf), 37 outbuf, sizeof(outbuf), &outlen); 38 if (rc) 39 return rc; 40 if (outlen < sizeof(outbuf)) 41 return -EIO; 42 *id = MCDI_DWORD(outbuf, MAE_MPORT_LOOKUP_OUT_MPORT_ID); 43 return 0; 44 } 45