136ff6393SMartin Habets /* SPDX-License-Identifier: GPL-2.0-only */ 236ff6393SMartin Habets /**************************************************************************** 336ff6393SMartin Habets * Driver for Solarflare network controllers and boards 436ff6393SMartin Habets * Copyright 2015 Solarflare Communications Inc. 536ff6393SMartin Habets */ 636ff6393SMartin Habets 736ff6393SMartin Habets #ifndef SIENA_SRIOV_H 836ff6393SMartin Habets #define SIENA_SRIOV_H 936ff6393SMartin Habets 1036ff6393SMartin Habets #include "net_driver.h" 1136ff6393SMartin Habets 1236ff6393SMartin Habets /* On the SFC9000 family each port is associated with 1 PCI physical 1336ff6393SMartin Habets * function (PF) handled by sfc and a configurable number of virtual 1436ff6393SMartin Habets * functions (VFs) that may be handled by some other driver, often in 1536ff6393SMartin Habets * a VM guest. The queue pointer registers are mapped in both PF and 1636ff6393SMartin Habets * VF BARs such that an 8K region provides access to a single RX, TX 1736ff6393SMartin Habets * and event queue (collectively a Virtual Interface, VI or VNIC). 1836ff6393SMartin Habets * 1936ff6393SMartin Habets * The PF has access to all 1024 VIs while VFs are mapped to VIs 2036ff6393SMartin Habets * according to VI_BASE and VI_SCALE: VF i has access to VIs numbered 2136ff6393SMartin Habets * in range [VI_BASE + i << VI_SCALE, VI_BASE + i + 1 << VI_SCALE). 2236ff6393SMartin Habets * The number of VIs and the VI_SCALE value are configurable but must 2336ff6393SMartin Habets * be established at boot time by firmware. 2436ff6393SMartin Habets */ 2536ff6393SMartin Habets 2636ff6393SMartin Habets /* Maximum VI_SCALE parameter supported by Siena */ 2736ff6393SMartin Habets #define EFX_VI_SCALE_MAX 6 2836ff6393SMartin Habets /* Base VI to use for SR-IOV. Must be aligned to (1 << EFX_VI_SCALE_MAX), 2936ff6393SMartin Habets * so this is the smallest allowed value. 3036ff6393SMartin Habets */ 3136ff6393SMartin Habets #define EFX_VI_BASE 128U 3236ff6393SMartin Habets /* Maximum number of VFs allowed */ 3336ff6393SMartin Habets #define EFX_VF_COUNT_MAX 127 3436ff6393SMartin Habets /* Limit EVQs on VFs to be only 8k to reduce buffer table reservation */ 3536ff6393SMartin Habets #define EFX_MAX_VF_EVQ_SIZE 8192UL 3636ff6393SMartin Habets /* The number of buffer table entries reserved for each VI on a VF */ 3736ff6393SMartin Habets #define EFX_VF_BUFTBL_PER_VI \ 3836ff6393SMartin Habets ((EFX_MAX_VF_EVQ_SIZE + 2 * EFX_MAX_DMAQ_SIZE) * \ 3936ff6393SMartin Habets sizeof(efx_qword_t) / EFX_BUF_SIZE) 4036ff6393SMartin Habets 4136ff6393SMartin Habets int efx_siena_sriov_configure(struct efx_nic *efx, int num_vfs); 4236ff6393SMartin Habets int efx_siena_sriov_init(struct efx_nic *efx); 4336ff6393SMartin Habets void efx_siena_sriov_fini(struct efx_nic *efx); 4436ff6393SMartin Habets int efx_siena_sriov_mac_address_changed(struct efx_nic *efx); 4536ff6393SMartin Habets bool efx_siena_sriov_wanted(struct efx_nic *efx); 4636ff6393SMartin Habets void efx_siena_sriov_reset(struct efx_nic *efx); 4736ff6393SMartin Habets void efx_siena_sriov_flr(struct efx_nic *efx, unsigned flr); 4836ff6393SMartin Habets 4936ff6393SMartin Habets int efx_siena_sriov_set_vf_mac(struct efx_nic *efx, int vf, const u8 *mac); 5036ff6393SMartin Habets int efx_siena_sriov_set_vf_vlan(struct efx_nic *efx, int vf, 5136ff6393SMartin Habets u16 vlan, u8 qos); 5236ff6393SMartin Habets int efx_siena_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf, 5336ff6393SMartin Habets bool spoofchk); 5436ff6393SMartin Habets int efx_siena_sriov_get_vf_config(struct efx_nic *efx, int vf, 5536ff6393SMartin Habets struct ifla_vf_info *ivf); 5636ff6393SMartin Habets 57*dfb1cfbdSMartin Habets #ifdef CONFIG_SFC_SIENA_SRIOV 5836ff6393SMartin Habets 5936ff6393SMartin Habets static inline bool efx_siena_sriov_enabled(struct efx_nic *efx) 6036ff6393SMartin Habets { 6136ff6393SMartin Habets return efx->vf_init_count != 0; 6236ff6393SMartin Habets } 63*dfb1cfbdSMartin Habets #else /* !CONFIG_SFC_SIENA_SRIOV */ 6436ff6393SMartin Habets static inline bool efx_siena_sriov_enabled(struct efx_nic *efx) 6536ff6393SMartin Habets { 6636ff6393SMartin Habets return false; 6736ff6393SMartin Habets } 68*dfb1cfbdSMartin Habets #endif /* CONFIG_SFC_SIENA_SRIOV */ 6936ff6393SMartin Habets 7036ff6393SMartin Habets void efx_siena_sriov_probe(struct efx_nic *efx); 7136ff6393SMartin Habets void efx_siena_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event); 7236ff6393SMartin Habets void efx_siena_sriov_rx_flush_done(struct efx_nic *efx, efx_qword_t *event); 7336ff6393SMartin Habets void efx_siena_sriov_event(struct efx_channel *channel, efx_qword_t *event); 7436ff6393SMartin Habets void efx_siena_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq); 7536ff6393SMartin Habets 7636ff6393SMartin Habets #endif /* SIENA_SRIOV_H */ 77