Skip to content

Commit 02246a7

Browse files
sshah-solarflaredavem330
authored andcommitted
sfc: Prepare to bind the sfc driver to the VF.
Added efx_nic_type structure for VF. Mapped a different BAR for VF as it uses BAR 0 for memory. Added functions sriov_init and sriov_fini. Signed-off-by: Shradha Shah <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1cd9ecb commit 02246a7

File tree

9 files changed

+175
-15
lines changed

9 files changed

+175
-15
lines changed

drivers/net/ethernet/sfc/ef10.c

Lines changed: 138 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ static int efx_ef10_get_warm_boot_count(struct efx_nic *efx)
9393

9494
static unsigned int efx_ef10_mem_map_size(struct efx_nic *efx)
9595
{
96-
return resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]);
96+
int bar;
97+
98+
bar = efx->type->mem_bar;
99+
return resource_size(&efx->pci_dev->resource[bar]);
97100
}
98101

99102
static int efx_ef10_get_pf_index(struct efx_nic *efx)
@@ -204,7 +207,7 @@ static int efx_ef10_probe(struct efx_nic *efx)
204207
efx->max_channels =
205208
min_t(unsigned int,
206209
EFX_MAX_CHANNELS,
207-
resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]) /
210+
efx_ef10_mem_map_size(efx) /
208211
(EFX_VI_PAGE_SIZE * EFX_TXQ_TYPES));
209212
if (WARN_ON(efx->max_channels == 0))
210213
return -EIO;
@@ -311,6 +314,23 @@ static int efx_ef10_probe(struct efx_nic *efx)
311314
return rc;
312315
}
313316

317+
static int efx_ef10_probe_pf(struct efx_nic *efx)
318+
{
319+
return efx_ef10_probe(efx);
320+
}
321+
322+
#ifdef CONFIG_SFC_SRIOV
323+
static int efx_ef10_probe_vf(struct efx_nic *efx)
324+
{
325+
return efx_ef10_probe(efx);
326+
}
327+
#else
328+
static int efx_ef10_probe_vf(struct efx_nic *efx __attribute__ ((unused)))
329+
{
330+
return 0;
331+
}
332+
#endif
333+
314334
static int efx_ef10_free_vis(struct efx_nic *efx)
315335
{
316336
MCDI_DECLARE_BUF_OUT_OR_ERR(outbuf, 0);
@@ -1076,6 +1096,14 @@ static void efx_ef10_push_irq_moderation(struct efx_channel *channel)
10761096
}
10771097
}
10781098

1099+
static void efx_ef10_get_wol_vf(struct efx_nic *efx,
1100+
struct ethtool_wolinfo *wol) {}
1101+
1102+
static int efx_ef10_set_wol_vf(struct efx_nic *efx, u32 type)
1103+
{
1104+
return -EOPNOTSUPP;
1105+
}
1106+
10791107
static void efx_ef10_get_wol(struct efx_nic *efx, struct ethtool_wolinfo *wol)
10801108
{
10811109
wol->supported = 0;
@@ -3534,6 +3562,9 @@ static void efx_ef10_ptp_write_host_time(struct efx_nic *efx, u32 host_time)
35343562
_efx_writed(efx, cpu_to_le32(host_time), ER_DZ_MC_DB_LWRD);
35353563
}
35363564

3565+
static void efx_ef10_ptp_write_host_time_vf(struct efx_nic *efx,
3566+
u32 host_time) {}
3567+
35373568
static int efx_ef10_rx_enable_timestamping(struct efx_channel *channel,
35383569
bool temp)
35393570
{
@@ -3611,6 +3642,12 @@ static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en,
36113642
return 0;
36123643
}
36133644

3645+
static int efx_ef10_ptp_set_ts_config_vf(struct efx_nic *efx,
3646+
struct hwtstamp_config *init)
3647+
{
3648+
return -EOPNOTSUPP;
3649+
}
3650+
36143651
static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
36153652
struct hwtstamp_config *init)
36163653
{
@@ -3647,9 +3684,107 @@ static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
36473684
}
36483685
}
36493686

3687+
const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
3688+
.mem_bar = EFX_MEM_VF_BAR,
3689+
.mem_map_size = efx_ef10_mem_map_size,
3690+
.probe = efx_ef10_probe_vf,
3691+
.remove = efx_ef10_remove,
3692+
.dimension_resources = efx_ef10_dimension_resources,
3693+
.init = efx_ef10_init_nic,
3694+
.fini = efx_port_dummy_op_void,
3695+
.map_reset_reason = efx_mcdi_map_reset_reason,
3696+
.map_reset_flags = efx_ef10_map_reset_flags,
3697+
.reset = efx_ef10_reset,
3698+
.probe_port = efx_mcdi_port_probe,
3699+
.remove_port = efx_mcdi_port_remove,
3700+
.fini_dmaq = efx_ef10_fini_dmaq,
3701+
.prepare_flr = efx_ef10_prepare_flr,
3702+
.finish_flr = efx_port_dummy_op_void,
3703+
.describe_stats = efx_ef10_describe_stats,
3704+
.update_stats = efx_ef10_update_stats,
3705+
.start_stats = efx_port_dummy_op_void,
3706+
.pull_stats = efx_port_dummy_op_void,
3707+
.stop_stats = efx_port_dummy_op_void,
3708+
.set_id_led = efx_mcdi_set_id_led,
3709+
.push_irq_moderation = efx_ef10_push_irq_moderation,
3710+
.reconfigure_mac = efx_ef10_mac_reconfigure,
3711+
.check_mac_fault = efx_mcdi_mac_check_fault,
3712+
.reconfigure_port = efx_mcdi_port_reconfigure,
3713+
.get_wol = efx_ef10_get_wol_vf,
3714+
.set_wol = efx_ef10_set_wol_vf,
3715+
.resume_wol = efx_port_dummy_op_void,
3716+
.mcdi_request = efx_ef10_mcdi_request,
3717+
.mcdi_poll_response = efx_ef10_mcdi_poll_response,
3718+
.mcdi_read_response = efx_ef10_mcdi_read_response,
3719+
.mcdi_poll_reboot = efx_ef10_mcdi_poll_reboot,
3720+
.irq_enable_master = efx_port_dummy_op_void,
3721+
.irq_test_generate = efx_ef10_irq_test_generate,
3722+
.irq_disable_non_ev = efx_port_dummy_op_void,
3723+
.irq_handle_msi = efx_ef10_msi_interrupt,
3724+
.irq_handle_legacy = efx_ef10_legacy_interrupt,
3725+
.tx_probe = efx_ef10_tx_probe,
3726+
.tx_init = efx_ef10_tx_init,
3727+
.tx_remove = efx_ef10_tx_remove,
3728+
.tx_write = efx_ef10_tx_write,
3729+
.rx_push_rss_config = efx_ef10_rx_push_rss_config,
3730+
.rx_probe = efx_ef10_rx_probe,
3731+
.rx_init = efx_ef10_rx_init,
3732+
.rx_remove = efx_ef10_rx_remove,
3733+
.rx_write = efx_ef10_rx_write,
3734+
.rx_defer_refill = efx_ef10_rx_defer_refill,
3735+
.ev_probe = efx_ef10_ev_probe,
3736+
.ev_init = efx_ef10_ev_init,
3737+
.ev_fini = efx_ef10_ev_fini,
3738+
.ev_remove = efx_ef10_ev_remove,
3739+
.ev_process = efx_ef10_ev_process,
3740+
.ev_read_ack = efx_ef10_ev_read_ack,
3741+
.ev_test_generate = efx_ef10_ev_test_generate,
3742+
.filter_table_probe = efx_ef10_filter_table_probe,
3743+
.filter_table_restore = efx_ef10_filter_table_restore,
3744+
.filter_table_remove = efx_ef10_filter_table_remove,
3745+
.filter_update_rx_scatter = efx_ef10_filter_update_rx_scatter,
3746+
.filter_insert = efx_ef10_filter_insert,
3747+
.filter_remove_safe = efx_ef10_filter_remove_safe,
3748+
.filter_get_safe = efx_ef10_filter_get_safe,
3749+
.filter_clear_rx = efx_ef10_filter_clear_rx,
3750+
.filter_count_rx_used = efx_ef10_filter_count_rx_used,
3751+
.filter_get_rx_id_limit = efx_ef10_filter_get_rx_id_limit,
3752+
.filter_get_rx_ids = efx_ef10_filter_get_rx_ids,
3753+
#ifdef CONFIG_RFS_ACCEL
3754+
.filter_rfs_insert = efx_ef10_filter_rfs_insert,
3755+
.filter_rfs_expire_one = efx_ef10_filter_rfs_expire_one,
3756+
#endif
3757+
#ifdef CONFIG_SFC_MTD
3758+
.mtd_probe = efx_port_dummy_op_int,
3759+
#endif
3760+
.ptp_write_host_time = efx_ef10_ptp_write_host_time_vf,
3761+
.ptp_set_ts_config = efx_ef10_ptp_set_ts_config_vf,
3762+
#ifdef CONFIG_SFC_SRIOV
3763+
.vswitching_probe = efx_port_dummy_op_int,
3764+
.vswitching_restore = efx_port_dummy_op_int,
3765+
.vswitching_remove = efx_port_dummy_op_void,
3766+
#endif
3767+
.revision = EFX_REV_HUNT_A0,
3768+
.max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH),
3769+
.rx_prefix_size = ES_DZ_RX_PREFIX_SIZE,
3770+
.rx_hash_offset = ES_DZ_RX_PREFIX_HASH_OFST,
3771+
.rx_ts_offset = ES_DZ_RX_PREFIX_TSTAMP_OFST,
3772+
.can_rx_scatter = true,
3773+
.always_rx_scatter = true,
3774+
.max_interrupt_mode = EFX_INT_MODE_MSIX,
3775+
.timer_period_max = 1 << ERF_DD_EVQ_IND_TIMER_VAL_WIDTH,
3776+
.offload_features = (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
3777+
NETIF_F_RXHASH | NETIF_F_NTUPLE),
3778+
.mcdi_max_ver = 2,
3779+
.max_rx_ip_filters = HUNT_FILTER_TBL_ROWS,
3780+
.hwtstamp_filters = 1 << HWTSTAMP_FILTER_NONE |
3781+
1 << HWTSTAMP_FILTER_ALL,
3782+
};
3783+
36503784
const struct efx_nic_type efx_hunt_a0_nic_type = {
3785+
.mem_bar = EFX_MEM_BAR,
36513786
.mem_map_size = efx_ef10_mem_map_size,
3652-
.probe = efx_ef10_probe,
3787+
.probe = efx_ef10_probe_pf,
36533788
.remove = efx_ef10_remove,
36543789
.dimension_resources = efx_ef10_dimension_resources,
36553790
.init = efx_ef10_init_nic,

drivers/net/ethernet/sfc/ef10_sriov.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs)
4646
return efx_ef10_pci_sriov_enable(efx, num_vfs);
4747
}
4848

49+
int efx_ef10_sriov_init(struct efx_nic *efx)
50+
{
51+
return 0;
52+
}
53+
54+
void efx_ef10_sriov_fini(struct efx_nic *efx)
55+
{
56+
int rc;
57+
58+
rc = efx_ef10_pci_sriov_disable(efx);
59+
if (rc)
60+
netif_dbg(efx, drv, efx->net_dev,
61+
"Disabling SRIOV was not successful rc=%d\n", rc);
62+
else
63+
netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n");
64+
}
65+
4966
static int efx_ef10_vswitch_alloc(struct efx_nic *efx, unsigned int port_id,
5067
unsigned int vswitch_type)
5168
{

drivers/net/ethernet/sfc/ef10_sriov.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@ static inline bool efx_ef10_sriov_wanted(struct efx_nic *efx)
1818
}
1919

2020
int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs);
21-
22-
static inline int efx_ef10_sriov_init(struct efx_nic *efx)
23-
{
24-
return -EOPNOTSUPP;
25-
}
26-
21+
int efx_ef10_sriov_init(struct efx_nic *efx);
2722
static inline void efx_ef10_sriov_mac_address_changed(struct efx_nic *efx) {}
2823
static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {}
29-
static inline void efx_ef10_sriov_fini(struct efx_nic *efx) {}
24+
void efx_ef10_sriov_fini(struct efx_nic *efx);
3025
static inline void efx_ef10_sriov_flr(struct efx_nic *efx, unsigned vf_i) {}
3126

3227
static inline int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf,

drivers/net/ethernet/sfc/efx.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,10 +1201,12 @@ static int efx_init_io(struct efx_nic *efx)
12011201
struct pci_dev *pci_dev = efx->pci_dev;
12021202
dma_addr_t dma_mask = efx->type->max_dma_mask;
12031203
unsigned int mem_map_size = efx->type->mem_map_size(efx);
1204-
int rc;
1204+
int rc, bar;
12051205

12061206
netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n");
12071207

1208+
bar = efx->type->mem_bar;
1209+
12081210
rc = pci_enable_device(pci_dev);
12091211
if (rc) {
12101212
netif_err(efx, probe, efx->net_dev,
@@ -1235,8 +1237,8 @@ static int efx_init_io(struct efx_nic *efx)
12351237
netif_dbg(efx, probe, efx->net_dev,
12361238
"using DMA mask %llx\n", (unsigned long long) dma_mask);
12371239

1238-
efx->membase_phys = pci_resource_start(efx->pci_dev, EFX_MEM_BAR);
1239-
rc = pci_request_region(pci_dev, EFX_MEM_BAR, "sfc");
1240+
efx->membase_phys = pci_resource_start(efx->pci_dev, bar);
1241+
rc = pci_request_region(pci_dev, bar, "sfc");
12401242
if (rc) {
12411243
netif_err(efx, probe, efx->net_dev,
12421244
"request for memory BAR failed\n");
@@ -1259,7 +1261,7 @@ static int efx_init_io(struct efx_nic *efx)
12591261
return 0;
12601262

12611263
fail4:
1262-
pci_release_region(efx->pci_dev, EFX_MEM_BAR);
1264+
pci_release_region(efx->pci_dev, bar);
12631265
fail3:
12641266
efx->membase_phys = 0;
12651267
fail2:
@@ -1270,6 +1272,8 @@ static int efx_init_io(struct efx_nic *efx)
12701272

12711273
static void efx_fini_io(struct efx_nic *efx)
12721274
{
1275+
int bar;
1276+
12731277
netif_dbg(efx, drv, efx->net_dev, "shutting down I/O\n");
12741278

12751279
if (efx->membase) {
@@ -1278,7 +1282,8 @@ static void efx_fini_io(struct efx_nic *efx)
12781282
}
12791283

12801284
if (efx->membase_phys) {
1281-
pci_release_region(efx->pci_dev, EFX_MEM_BAR);
1285+
bar = efx->type->mem_bar;
1286+
pci_release_region(efx->pci_dev, bar);
12821287
efx->membase_phys = 0;
12831288
}
12841289

drivers/net/ethernet/sfc/efx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#include "filter.h"
1616

1717
/* All controllers use BAR 0 for I/O space and BAR 2(&3) for memory */
18+
/* All VFs use BAR 0/1 for memory */
1819
#define EFX_MEM_BAR 2
20+
#define EFX_MEM_VF_BAR 0
1921

2022
/* TX */
2123
int efx_probe_tx_queue(struct efx_tx_queue *tx_queue);

drivers/net/ethernet/sfc/falcon.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,6 +2687,7 @@ static int falcon_set_wol(struct efx_nic *efx, u32 type)
26872687
*/
26882688

26892689
const struct efx_nic_type falcon_a1_nic_type = {
2690+
.mem_bar = EFX_MEM_BAR,
26902691
.mem_map_size = falcon_a1_mem_map_size,
26912692
.probe = falcon_probe_nic,
26922693
.remove = falcon_remove_nic,
@@ -2783,6 +2784,7 @@ const struct efx_nic_type falcon_a1_nic_type = {
27832784
};
27842785

27852786
const struct efx_nic_type falcon_b0_nic_type = {
2787+
.mem_bar = EFX_MEM_BAR,
27862788
.mem_map_size = falcon_b0_mem_map_size,
27872789
.probe = falcon_probe_nic,
27882790
.remove = falcon_remove_nic,

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@ struct efx_mtd_partition {
10891089

10901090
/**
10911091
* struct efx_nic_type - Efx device type definition
1092+
* @mem_bar: Get the memory BAR
10921093
* @mem_map_size: Get memory BAR mapped size
10931094
* @probe: Probe the controller
10941095
* @remove: Free resources allocated by probe()
@@ -1223,6 +1224,7 @@ struct efx_mtd_partition {
12231224
* @hwtstamp_filters: Mask of hardware timestamp filter types supported
12241225
*/
12251226
struct efx_nic_type {
1227+
unsigned int mem_bar;
12261228
unsigned int (*mem_map_size)(struct efx_nic *efx);
12271229
int (*probe)(struct efx_nic *efx);
12281230
void (*remove)(struct efx_nic *efx);

drivers/net/ethernet/sfc/nic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ extern const struct efx_nic_type falcon_a1_nic_type;
555555
extern const struct efx_nic_type falcon_b0_nic_type;
556556
extern const struct efx_nic_type siena_a0_nic_type;
557557
extern const struct efx_nic_type efx_hunt_a0_nic_type;
558+
extern const struct efx_nic_type efx_hunt_a0_vf_nic_type;
558559

559560
/**************************************************************************
560561
*

drivers/net/ethernet/sfc/siena.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ static int siena_mtd_probe(struct efx_nic *efx)
912912
*/
913913

914914
const struct efx_nic_type siena_a0_nic_type = {
915+
.mem_bar = EFX_MEM_BAR,
915916
.mem_map_size = siena_mem_map_size,
916917
.probe = siena_probe_nic,
917918
.remove = siena_remove_nic,

0 commit comments

Comments
 (0)