aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShradha Shah <sshah@solarflare.com>2014-11-05 07:16:18 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-06 14:43:08 -0500
commit2dc313eca30043978d749c1d37e3c62f3307575d (patch)
treea64d1082fc45a394d5e2d670a19d01456772e9cd
parent7e5d7753956b374516530e156c5e8aa19652398d (diff)
sfc: Move the current VF state from efx_nic into siena_nic_data
This patch series provides a base and cleanup for the upcoming EF10 SRIOV support. This patch moves the VF state into siena_nic_data as a basis to save the VF state based on nic type. Signed-off-by: Shradha Shah <sshah@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/sfc/farch.c11
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h14
-rw-r--r--drivers/net/ethernet/sfc/nic.h18
-rw-r--r--drivers/net/ethernet/sfc/siena.c1
-rw-r--r--drivers/net/ethernet/sfc/siena_sriov.c92
5 files changed, 84 insertions, 52 deletions
diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c
index 6859437b59fb..0274401cd4d8 100644
--- a/drivers/net/ethernet/sfc/farch.c
+++ b/drivers/net/ethernet/sfc/farch.c
@@ -226,6 +226,9 @@ static int efx_alloc_special_buffer(struct efx_nic *efx,
226 struct efx_special_buffer *buffer, 226 struct efx_special_buffer *buffer,
227 unsigned int len) 227 unsigned int len)
228{ 228{
229#ifdef CONFIG_SFC_SRIOV
230 struct siena_nic_data *nic_data = efx->nic_data;
231#endif
229 len = ALIGN(len, EFX_BUF_SIZE); 232 len = ALIGN(len, EFX_BUF_SIZE);
230 233
231 if (efx_nic_alloc_buffer(efx, &buffer->buf, len, GFP_KERNEL)) 234 if (efx_nic_alloc_buffer(efx, &buffer->buf, len, GFP_KERNEL))
@@ -238,7 +241,7 @@ static int efx_alloc_special_buffer(struct efx_nic *efx,
238 efx->next_buffer_table += buffer->entries; 241 efx->next_buffer_table += buffer->entries;
239#ifdef CONFIG_SFC_SRIOV 242#ifdef CONFIG_SFC_SRIOV
240 BUG_ON(efx_sriov_enabled(efx) && 243 BUG_ON(efx_sriov_enabled(efx) &&
241 efx->vf_buftbl_base < efx->next_buffer_table); 244 nic_data->vf_buftbl_base < efx->next_buffer_table);
242#endif 245#endif
243 246
244 netif_dbg(efx, probe, efx->net_dev, 247 netif_dbg(efx, probe, efx->net_dev,
@@ -1668,6 +1671,10 @@ void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw)
1668{ 1671{
1669 unsigned vi_count, buftbl_min; 1672 unsigned vi_count, buftbl_min;
1670 1673
1674#ifdef CONFIG_SFC_SRIOV
1675 struct siena_nic_data *nic_data = efx->nic_data;
1676#endif
1677
1671 /* Account for the buffer table entries backing the datapath channels 1678 /* Account for the buffer table entries backing the datapath channels
1672 * and the descriptor caches for those channels. 1679 * and the descriptor caches for those channels.
1673 */ 1680 */
@@ -1681,7 +1688,7 @@ void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw)
1681 if (efx_sriov_wanted(efx)) { 1688 if (efx_sriov_wanted(efx)) {
1682 unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit; 1689 unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit;
1683 1690
1684 efx->vf_buftbl_base = buftbl_min; 1691 nic_data->vf_buftbl_base = buftbl_min;
1685 1692
1686 vi_dc_entries = RX_DC_ENTRIES + TX_DC_ENTRIES; 1693 vi_dc_entries = RX_DC_ENTRIES + TX_DC_ENTRIES;
1687 vi_count = max(vi_count, EFX_VI_BASE); 1694 vi_count = max(vi_count, EFX_VI_BASE);
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index 9ede32064685..779a1f59a010 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -913,13 +913,6 @@ struct vfdi_status;
913 * @vf_count: Number of VFs intended to be enabled. 913 * @vf_count: Number of VFs intended to be enabled.
914 * @vf_init_count: Number of VFs that have been fully initialised. 914 * @vf_init_count: Number of VFs that have been fully initialised.
915 * @vi_scale: log2 number of vnics per VF. 915 * @vi_scale: log2 number of vnics per VF.
916 * @vf_buftbl_base: The zeroth buffer table index used to back VF queues.
917 * @vfdi_status: Common VFDI status page to be dmad to VF address space.
918 * @local_addr_list: List of local addresses. Protected by %local_lock.
919 * @local_page_list: List of DMA addressable pages used to broadcast
920 * %local_addr_list. Protected by %local_lock.
921 * @local_lock: Mutex protecting %local_addr_list and %local_page_list.
922 * @peer_work: Work item to broadcast peer addresses to VMs.
923 * @ptp_data: PTP state data 916 * @ptp_data: PTP state data
924 * @vpd_sn: Serial number read from VPD 917 * @vpd_sn: Serial number read from VPD
925 * @monitor_work: Hardware monitor workitem 918 * @monitor_work: Hardware monitor workitem
@@ -1060,17 +1053,10 @@ struct efx_nic {
1060 wait_queue_head_t flush_wq; 1053 wait_queue_head_t flush_wq;
1061 1054
1062#ifdef CONFIG_SFC_SRIOV 1055#ifdef CONFIG_SFC_SRIOV
1063 struct efx_channel *vfdi_channel;
1064 struct efx_vf *vf; 1056 struct efx_vf *vf;
1065 unsigned vf_count; 1057 unsigned vf_count;
1066 unsigned vf_init_count; 1058 unsigned vf_init_count;
1067 unsigned vi_scale; 1059 unsigned vi_scale;
1068 unsigned vf_buftbl_base;
1069 struct efx_buffer vfdi_status;
1070 struct list_head local_addr_list;
1071 struct list_head local_page_list;
1072 struct mutex local_lock;
1073 struct work_struct peer_work;
1074#endif 1060#endif
1075 1061
1076 struct efx_ptp_data *ptp_data; 1062 struct efx_ptp_data *ptp_data;
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h
index f77cce034ad4..b5fe1f2c7d88 100644
--- a/drivers/net/ethernet/sfc/nic.h
+++ b/drivers/net/ethernet/sfc/nic.h
@@ -378,12 +378,30 @@ enum {
378 378
379/** 379/**
380 * struct siena_nic_data - Siena NIC state 380 * struct siena_nic_data - Siena NIC state
381 * @efx: Pointer back to main interface structure
381 * @wol_filter_id: Wake-on-LAN packet filter id 382 * @wol_filter_id: Wake-on-LAN packet filter id
382 * @stats: Hardware statistics 383 * @stats: Hardware statistics
384 * @vf_buftbl_base: The zeroth buffer table index used to back VF queues.
385 * @vfdi_status: Common VFDI status page to be dmad to VF address space.
386 * @local_addr_list: List of local addresses. Protected by %local_lock.
387 * @local_page_list: List of DMA addressable pages used to broadcast
388 * %local_addr_list. Protected by %local_lock.
389 * @local_lock: Mutex protecting %local_addr_list and %local_page_list.
390 * @peer_work: Work item to broadcast peer addresses to VMs.
383 */ 391 */
384struct siena_nic_data { 392struct siena_nic_data {
393 struct efx_nic *efx;
385 int wol_filter_id; 394 int wol_filter_id;
386 u64 stats[SIENA_STAT_COUNT]; 395 u64 stats[SIENA_STAT_COUNT];
396#ifdef CONFIG_SFC_SRIOV
397 struct efx_channel *vfdi_channel;
398 unsigned vf_buftbl_base;
399 struct efx_buffer vfdi_status;
400 struct list_head local_addr_list;
401 struct list_head local_page_list;
402 struct mutex local_lock;
403 struct work_struct peer_work;
404#endif
387}; 405};
388 406
389enum { 407enum {
diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c
index ae696855f21a..ffce06db94d1 100644
--- a/drivers/net/ethernet/sfc/siena.c
+++ b/drivers/net/ethernet/sfc/siena.c
@@ -251,6 +251,7 @@ static int siena_probe_nic(struct efx_nic *efx)
251 nic_data = kzalloc(sizeof(struct siena_nic_data), GFP_KERNEL); 251 nic_data = kzalloc(sizeof(struct siena_nic_data), GFP_KERNEL);
252 if (!nic_data) 252 if (!nic_data)
253 return -ENOMEM; 253 return -ENOMEM;
254 nic_data->efx = efx;
254 efx->nic_data = nic_data; 255 efx->nic_data = nic_data;
255 256
256 if (efx_farch_fpga_ver(efx) != 0) { 257 if (efx_farch_fpga_ver(efx) != 0) {
diff --git a/drivers/net/ethernet/sfc/siena_sriov.c b/drivers/net/ethernet/sfc/siena_sriov.c
index 43d2e64546ed..2b75eee03b03 100644
--- a/drivers/net/ethernet/sfc/siena_sriov.c
+++ b/drivers/net/ethernet/sfc/siena_sriov.c
@@ -229,11 +229,12 @@ static int efx_sriov_cmd(struct efx_nic *efx, bool enable,
229 229
230static void efx_sriov_usrev(struct efx_nic *efx, bool enabled) 230static void efx_sriov_usrev(struct efx_nic *efx, bool enabled)
231{ 231{
232 struct siena_nic_data *nic_data = efx->nic_data;
232 efx_oword_t reg; 233 efx_oword_t reg;
233 234
234 EFX_POPULATE_OWORD_2(reg, 235 EFX_POPULATE_OWORD_2(reg,
235 FRF_CZ_USREV_DIS, enabled ? 0 : 1, 236 FRF_CZ_USREV_DIS, enabled ? 0 : 1,
236 FRF_CZ_DFLT_EVQ, efx->vfdi_channel->channel); 237 FRF_CZ_DFLT_EVQ, nic_data->vfdi_channel->channel);
237 efx_writeo(efx, &reg, FR_CZ_USR_EV_CFG); 238 efx_writeo(efx, &reg, FR_CZ_USR_EV_CFG);
238} 239}
239 240
@@ -382,9 +383,12 @@ static void efx_sriov_reset_rx_filter(struct efx_vf *vf)
382 383
383static void __efx_sriov_update_vf_addr(struct efx_vf *vf) 384static void __efx_sriov_update_vf_addr(struct efx_vf *vf)
384{ 385{
386 struct efx_nic *efx = vf->efx;
387 struct siena_nic_data *nic_data = efx->nic_data;
388
385 efx_sriov_reset_tx_filter(vf); 389 efx_sriov_reset_tx_filter(vf);
386 efx_sriov_reset_rx_filter(vf); 390 efx_sriov_reset_rx_filter(vf);
387 queue_work(vfdi_workqueue, &vf->efx->peer_work); 391 queue_work(vfdi_workqueue, &nic_data->peer_work);
388} 392}
389 393
390/* Push the peer list to this VF. The caller must hold status_lock to interlock 394/* Push the peer list to this VF. The caller must hold status_lock to interlock
@@ -395,7 +399,8 @@ static void __efx_sriov_update_vf_addr(struct efx_vf *vf)
395static void __efx_sriov_push_vf_status(struct efx_vf *vf) 399static void __efx_sriov_push_vf_status(struct efx_vf *vf)
396{ 400{
397 struct efx_nic *efx = vf->efx; 401 struct efx_nic *efx = vf->efx;
398 struct vfdi_status *status = efx->vfdi_status.addr; 402 struct siena_nic_data *nic_data = efx->nic_data;
403 struct vfdi_status *status = nic_data->vfdi_status.addr;
399 struct efx_memcpy_req copy[4]; 404 struct efx_memcpy_req copy[4];
400 struct efx_endpoint_page *epp; 405 struct efx_endpoint_page *epp;
401 unsigned int pos, count; 406 unsigned int pos, count;
@@ -421,7 +426,7 @@ static void __efx_sriov_push_vf_status(struct efx_vf *vf)
421 */ 426 */
422 data_offset = offsetof(struct vfdi_status, version); 427 data_offset = offsetof(struct vfdi_status, version);
423 copy[1].from_rid = efx->pci_dev->devfn; 428 copy[1].from_rid = efx->pci_dev->devfn;
424 copy[1].from_addr = efx->vfdi_status.dma_addr + data_offset; 429 copy[1].from_addr = nic_data->vfdi_status.dma_addr + data_offset;
425 copy[1].to_rid = vf->pci_rid; 430 copy[1].to_rid = vf->pci_rid;
426 copy[1].to_addr = vf->status_addr + data_offset; 431 copy[1].to_addr = vf->status_addr + data_offset;
427 copy[1].length = status->length - data_offset; 432 copy[1].length = status->length - data_offset;
@@ -429,7 +434,7 @@ static void __efx_sriov_push_vf_status(struct efx_vf *vf)
429 /* Copy the peer pages */ 434 /* Copy the peer pages */
430 pos = 2; 435 pos = 2;
431 count = 0; 436 count = 0;
432 list_for_each_entry(epp, &efx->local_page_list, link) { 437 list_for_each_entry(epp, &nic_data->local_page_list, link) {
433 if (count == vf->peer_page_count) { 438 if (count == vf->peer_page_count) {
434 /* The VF driver will know they need to provide more 439 /* The VF driver will know they need to provide more
435 * pages because peer_addr_count is too large. 440 * pages because peer_addr_count is too large.
@@ -754,6 +759,7 @@ static int efx_vfdi_fini_all_queues(struct efx_vf *vf)
754static int efx_vfdi_insert_filter(struct efx_vf *vf) 759static int efx_vfdi_insert_filter(struct efx_vf *vf)
755{ 760{
756 struct efx_nic *efx = vf->efx; 761 struct efx_nic *efx = vf->efx;
762 struct siena_nic_data *nic_data = efx->nic_data;
757 struct vfdi_req *req = vf->buf.addr; 763 struct vfdi_req *req = vf->buf.addr;
758 unsigned vf_rxq = req->u.mac_filter.rxq; 764 unsigned vf_rxq = req->u.mac_filter.rxq;
759 unsigned flags; 765 unsigned flags;
@@ -777,16 +783,19 @@ static int efx_vfdi_insert_filter(struct efx_vf *vf)
777 vf->rx_filtering = true; 783 vf->rx_filtering = true;
778 784
779 efx_sriov_reset_rx_filter(vf); 785 efx_sriov_reset_rx_filter(vf);
780 queue_work(vfdi_workqueue, &efx->peer_work); 786 queue_work(vfdi_workqueue, &nic_data->peer_work);
781 787
782 return VFDI_RC_SUCCESS; 788 return VFDI_RC_SUCCESS;
783} 789}
784 790
785static int efx_vfdi_remove_all_filters(struct efx_vf *vf) 791static int efx_vfdi_remove_all_filters(struct efx_vf *vf)
786{ 792{
793 struct efx_nic *efx = vf->efx;
794 struct siena_nic_data *nic_data = efx->nic_data;
795
787 vf->rx_filtering = false; 796 vf->rx_filtering = false;
788 efx_sriov_reset_rx_filter(vf); 797 efx_sriov_reset_rx_filter(vf);
789 queue_work(vfdi_workqueue, &vf->efx->peer_work); 798 queue_work(vfdi_workqueue, &nic_data->peer_work);
790 799
791 return VFDI_RC_SUCCESS; 800 return VFDI_RC_SUCCESS;
792} 801}
@@ -794,6 +803,7 @@ static int efx_vfdi_remove_all_filters(struct efx_vf *vf)
794static int efx_vfdi_set_status_page(struct efx_vf *vf) 803static int efx_vfdi_set_status_page(struct efx_vf *vf)
795{ 804{
796 struct efx_nic *efx = vf->efx; 805 struct efx_nic *efx = vf->efx;
806 struct siena_nic_data *nic_data = efx->nic_data;
797 struct vfdi_req *req = vf->buf.addr; 807 struct vfdi_req *req = vf->buf.addr;
798 u64 page_count = req->u.set_status_page.peer_page_count; 808 u64 page_count = req->u.set_status_page.peer_page_count;
799 u64 max_page_count = 809 u64 max_page_count =
@@ -809,7 +819,7 @@ static int efx_vfdi_set_status_page(struct efx_vf *vf)
809 return VFDI_RC_EINVAL; 819 return VFDI_RC_EINVAL;
810 } 820 }
811 821
812 mutex_lock(&efx->local_lock); 822 mutex_lock(&nic_data->local_lock);
813 mutex_lock(&vf->status_lock); 823 mutex_lock(&vf->status_lock);
814 vf->status_addr = req->u.set_status_page.dma_addr; 824 vf->status_addr = req->u.set_status_page.dma_addr;
815 825
@@ -830,7 +840,7 @@ static int efx_vfdi_set_status_page(struct efx_vf *vf)
830 840
831 __efx_sriov_push_vf_status(vf); 841 __efx_sriov_push_vf_status(vf);
832 mutex_unlock(&vf->status_lock); 842 mutex_unlock(&vf->status_lock);
833 mutex_unlock(&efx->local_lock); 843 mutex_unlock(&nic_data->local_lock);
834 844
835 return VFDI_RC_SUCCESS; 845 return VFDI_RC_SUCCESS;
836} 846}
@@ -1014,7 +1024,9 @@ static void efx_sriov_handle_no_channel(struct efx_nic *efx)
1014 1024
1015static int efx_sriov_probe_channel(struct efx_channel *channel) 1025static int efx_sriov_probe_channel(struct efx_channel *channel)
1016{ 1026{
1017 channel->efx->vfdi_channel = channel; 1027 struct siena_nic_data *nic_data = channel->efx->nic_data;
1028 nic_data->vfdi_channel = channel;
1029
1018 return 0; 1030 return 0;
1019} 1031}
1020 1032
@@ -1057,8 +1069,11 @@ void efx_sriov_probe(struct efx_nic *efx)
1057 */ 1069 */
1058static void efx_sriov_peer_work(struct work_struct *data) 1070static void efx_sriov_peer_work(struct work_struct *data)
1059{ 1071{
1060 struct efx_nic *efx = container_of(data, struct efx_nic, peer_work); 1072 struct siena_nic_data *nic_data = container_of(data,
1061 struct vfdi_status *vfdi_status = efx->vfdi_status.addr; 1073 struct siena_nic_data,
1074 peer_work);
1075 struct efx_nic *efx = nic_data->efx;
1076 struct vfdi_status *vfdi_status = nic_data->vfdi_status.addr;
1062 struct efx_vf *vf; 1077 struct efx_vf *vf;
1063 struct efx_local_addr *local_addr; 1078 struct efx_local_addr *local_addr;
1064 struct vfdi_endpoint *peer; 1079 struct vfdi_endpoint *peer;
@@ -1068,11 +1083,11 @@ static void efx_sriov_peer_work(struct work_struct *data)
1068 unsigned int peer_count; 1083 unsigned int peer_count;
1069 unsigned int pos; 1084 unsigned int pos;
1070 1085
1071 mutex_lock(&efx->local_lock); 1086 mutex_lock(&nic_data->local_lock);
1072 1087
1073 /* Move the existing peer pages off %local_page_list */ 1088 /* Move the existing peer pages off %local_page_list */
1074 INIT_LIST_HEAD(&pages); 1089 INIT_LIST_HEAD(&pages);
1075 list_splice_tail_init(&efx->local_page_list, &pages); 1090 list_splice_tail_init(&nic_data->local_page_list, &pages);
1076 1091
1077 /* Populate the VF addresses starting from entry 1 (entry 0 is 1092 /* Populate the VF addresses starting from entry 1 (entry 0 is
1078 * the PF address) 1093 * the PF address)
@@ -1094,7 +1109,7 @@ static void efx_sriov_peer_work(struct work_struct *data)
1094 } 1109 }
1095 1110
1096 /* Fill the remaining addresses */ 1111 /* Fill the remaining addresses */
1097 list_for_each_entry(local_addr, &efx->local_addr_list, link) { 1112 list_for_each_entry(local_addr, &nic_data->local_addr_list, link) {
1098 ether_addr_copy(peer->mac_addr, local_addr->addr); 1113 ether_addr_copy(peer->mac_addr, local_addr->addr);
1099 peer->tci = 0; 1114 peer->tci = 0;
1100 ++peer; 1115 ++peer;
@@ -1117,13 +1132,13 @@ static void efx_sriov_peer_work(struct work_struct *data)
1117 list_del(&epp->link); 1132 list_del(&epp->link);
1118 } 1133 }
1119 1134
1120 list_add_tail(&epp->link, &efx->local_page_list); 1135 list_add_tail(&epp->link, &nic_data->local_page_list);
1121 peer = (struct vfdi_endpoint *)epp->ptr; 1136 peer = (struct vfdi_endpoint *)epp->ptr;
1122 peer_space = EFX_PAGE_SIZE / sizeof(struct vfdi_endpoint); 1137 peer_space = EFX_PAGE_SIZE / sizeof(struct vfdi_endpoint);
1123 } 1138 }
1124 } 1139 }
1125 vfdi_status->peer_count = peer_count; 1140 vfdi_status->peer_count = peer_count;
1126 mutex_unlock(&efx->local_lock); 1141 mutex_unlock(&nic_data->local_lock);
1127 1142
1128 /* Free any now unused endpoint pages */ 1143 /* Free any now unused endpoint pages */
1129 while (!list_empty(&pages)) { 1144 while (!list_empty(&pages)) {
@@ -1148,18 +1163,19 @@ static void efx_sriov_peer_work(struct work_struct *data)
1148 1163
1149static void efx_sriov_free_local(struct efx_nic *efx) 1164static void efx_sriov_free_local(struct efx_nic *efx)
1150{ 1165{
1166 struct siena_nic_data *nic_data = efx->nic_data;
1151 struct efx_local_addr *local_addr; 1167 struct efx_local_addr *local_addr;
1152 struct efx_endpoint_page *epp; 1168 struct efx_endpoint_page *epp;
1153 1169
1154 while (!list_empty(&efx->local_addr_list)) { 1170 while (!list_empty(&nic_data->local_addr_list)) {
1155 local_addr = list_first_entry(&efx->local_addr_list, 1171 local_addr = list_first_entry(&nic_data->local_addr_list,
1156 struct efx_local_addr, link); 1172 struct efx_local_addr, link);
1157 list_del(&local_addr->link); 1173 list_del(&local_addr->link);
1158 kfree(local_addr); 1174 kfree(local_addr);
1159 } 1175 }
1160 1176
1161 while (!list_empty(&efx->local_page_list)) { 1177 while (!list_empty(&nic_data->local_page_list)) {
1162 epp = list_first_entry(&efx->local_page_list, 1178 epp = list_first_entry(&nic_data->local_page_list,
1163 struct efx_endpoint_page, link); 1179 struct efx_endpoint_page, link);
1164 list_del(&epp->link); 1180 list_del(&epp->link);
1165 dma_free_coherent(&efx->pci_dev->dev, EFX_PAGE_SIZE, 1181 dma_free_coherent(&efx->pci_dev->dev, EFX_PAGE_SIZE,
@@ -1215,6 +1231,7 @@ static void efx_sriov_vfs_fini(struct efx_nic *efx)
1215static int efx_sriov_vfs_init(struct efx_nic *efx) 1231static int efx_sriov_vfs_init(struct efx_nic *efx)
1216{ 1232{
1217 struct pci_dev *pci_dev = efx->pci_dev; 1233 struct pci_dev *pci_dev = efx->pci_dev;
1234 struct siena_nic_data *nic_data = efx->nic_data;
1218 unsigned index, devfn, sriov, buftbl_base; 1235 unsigned index, devfn, sriov, buftbl_base;
1219 u16 offset, stride; 1236 u16 offset, stride;
1220 struct efx_vf *vf; 1237 struct efx_vf *vf;
@@ -1227,7 +1244,7 @@ static int efx_sriov_vfs_init(struct efx_nic *efx)
1227 pci_read_config_word(pci_dev, sriov + PCI_SRIOV_VF_OFFSET, &offset); 1244 pci_read_config_word(pci_dev, sriov + PCI_SRIOV_VF_OFFSET, &offset);
1228 pci_read_config_word(pci_dev, sriov + PCI_SRIOV_VF_STRIDE, &stride); 1245 pci_read_config_word(pci_dev, sriov + PCI_SRIOV_VF_STRIDE, &stride);
1229 1246
1230 buftbl_base = efx->vf_buftbl_base; 1247 buftbl_base = nic_data->vf_buftbl_base;
1231 devfn = pci_dev->devfn + offset; 1248 devfn = pci_dev->devfn + offset;
1232 for (index = 0; index < efx->vf_count; ++index) { 1249 for (index = 0; index < efx->vf_count; ++index) {
1233 vf = efx->vf + index; 1250 vf = efx->vf + index;
@@ -1260,6 +1277,7 @@ fail:
1260int efx_sriov_init(struct efx_nic *efx) 1277int efx_sriov_init(struct efx_nic *efx)
1261{ 1278{
1262 struct net_device *net_dev = efx->net_dev; 1279 struct net_device *net_dev = efx->net_dev;
1280 struct siena_nic_data *nic_data = efx->nic_data;
1263 struct vfdi_status *vfdi_status; 1281 struct vfdi_status *vfdi_status;
1264 int rc; 1282 int rc;
1265 1283
@@ -1275,11 +1293,11 @@ int efx_sriov_init(struct efx_nic *efx)
1275 if (rc) 1293 if (rc)
1276 goto fail_cmd; 1294 goto fail_cmd;
1277 1295
1278 rc = efx_nic_alloc_buffer(efx, &efx->vfdi_status, sizeof(*vfdi_status), 1296 rc = efx_nic_alloc_buffer(efx, &nic_data->vfdi_status,
1279 GFP_KERNEL); 1297 sizeof(*vfdi_status), GFP_KERNEL);
1280 if (rc) 1298 if (rc)
1281 goto fail_status; 1299 goto fail_status;
1282 vfdi_status = efx->vfdi_status.addr; 1300 vfdi_status = nic_data->vfdi_status.addr;
1283 memset(vfdi_status, 0, sizeof(*vfdi_status)); 1301 memset(vfdi_status, 0, sizeof(*vfdi_status));
1284 vfdi_status->version = 1; 1302 vfdi_status->version = 1;
1285 vfdi_status->length = sizeof(*vfdi_status); 1303 vfdi_status->length = sizeof(*vfdi_status);
@@ -1293,10 +1311,10 @@ int efx_sriov_init(struct efx_nic *efx)
1293 if (rc) 1311 if (rc)
1294 goto fail_alloc; 1312 goto fail_alloc;
1295 1313
1296 mutex_init(&efx->local_lock); 1314 mutex_init(&nic_data->local_lock);
1297 INIT_WORK(&efx->peer_work, efx_sriov_peer_work); 1315 INIT_WORK(&nic_data->peer_work, efx_sriov_peer_work);
1298 INIT_LIST_HEAD(&efx->local_addr_list); 1316 INIT_LIST_HEAD(&nic_data->local_addr_list);
1299 INIT_LIST_HEAD(&efx->local_page_list); 1317 INIT_LIST_HEAD(&nic_data->local_page_list);
1300 1318
1301 rc = efx_sriov_vfs_init(efx); 1319 rc = efx_sriov_vfs_init(efx);
1302 if (rc) 1320 if (rc)
@@ -1327,11 +1345,11 @@ fail_pci:
1327 rtnl_unlock(); 1345 rtnl_unlock();
1328 efx_sriov_vfs_fini(efx); 1346 efx_sriov_vfs_fini(efx);
1329fail_vfs: 1347fail_vfs:
1330 cancel_work_sync(&efx->peer_work); 1348 cancel_work_sync(&nic_data->peer_work);
1331 efx_sriov_free_local(efx); 1349 efx_sriov_free_local(efx);
1332 kfree(efx->vf); 1350 kfree(efx->vf);
1333fail_alloc: 1351fail_alloc:
1334 efx_nic_free_buffer(efx, &efx->vfdi_status); 1352 efx_nic_free_buffer(efx, &nic_data->vfdi_status);
1335fail_status: 1353fail_status:
1336 efx_sriov_cmd(efx, false, NULL, NULL); 1354 efx_sriov_cmd(efx, false, NULL, NULL);
1337fail_cmd: 1355fail_cmd:
@@ -1342,12 +1360,13 @@ void efx_sriov_fini(struct efx_nic *efx)
1342{ 1360{
1343 struct efx_vf *vf; 1361 struct efx_vf *vf;
1344 unsigned int pos; 1362 unsigned int pos;
1363 struct siena_nic_data *nic_data = efx->nic_data;
1345 1364
1346 if (efx->vf_init_count == 0) 1365 if (efx->vf_init_count == 0)
1347 return; 1366 return;
1348 1367
1349 /* Disable all interfaces to reconfiguration */ 1368 /* Disable all interfaces to reconfiguration */
1350 BUG_ON(efx->vfdi_channel->enabled); 1369 BUG_ON(nic_data->vfdi_channel->enabled);
1351 efx_sriov_usrev(efx, false); 1370 efx_sriov_usrev(efx, false);
1352 rtnl_lock(); 1371 rtnl_lock();
1353 efx->vf_init_count = 0; 1372 efx->vf_init_count = 0;
@@ -1359,7 +1378,7 @@ void efx_sriov_fini(struct efx_nic *efx)
1359 cancel_work_sync(&vf->req); 1378 cancel_work_sync(&vf->req);
1360 cancel_work_sync(&vf->reset_work); 1379 cancel_work_sync(&vf->reset_work);
1361 } 1380 }
1362 cancel_work_sync(&efx->peer_work); 1381 cancel_work_sync(&nic_data->peer_work);
1363 1382
1364 pci_disable_sriov(efx->pci_dev); 1383 pci_disable_sriov(efx->pci_dev);
1365 1384
@@ -1367,7 +1386,7 @@ void efx_sriov_fini(struct efx_nic *efx)
1367 efx_sriov_vfs_fini(efx); 1386 efx_sriov_vfs_fini(efx);
1368 efx_sriov_free_local(efx); 1387 efx_sriov_free_local(efx);
1369 kfree(efx->vf); 1388 kfree(efx->vf);
1370 efx_nic_free_buffer(efx, &efx->vfdi_status); 1389 efx_nic_free_buffer(efx, &nic_data->vfdi_status);
1371 efx_sriov_cmd(efx, false, NULL, NULL); 1390 efx_sriov_cmd(efx, false, NULL, NULL);
1372} 1391}
1373 1392
@@ -1447,13 +1466,14 @@ void efx_sriov_flr(struct efx_nic *efx, unsigned vf_i)
1447 1466
1448void efx_sriov_mac_address_changed(struct efx_nic *efx) 1467void efx_sriov_mac_address_changed(struct efx_nic *efx)
1449{ 1468{
1450 struct vfdi_status *vfdi_status = efx->vfdi_status.addr; 1469 struct siena_nic_data *nic_data = efx->nic_data;
1470 struct vfdi_status *vfdi_status = nic_data->vfdi_status.addr;
1451 1471
1452 if (!efx->vf_init_count) 1472 if (!efx->vf_init_count)
1453 return; 1473 return;
1454 ether_addr_copy(vfdi_status->peers[0].mac_addr, 1474 ether_addr_copy(vfdi_status->peers[0].mac_addr,
1455 efx->net_dev->dev_addr); 1475 efx->net_dev->dev_addr);
1456 queue_work(vfdi_workqueue, &efx->peer_work); 1476 queue_work(vfdi_workqueue, &nic_data->peer_work);
1457} 1477}
1458 1478
1459void efx_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event) 1479void efx_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event)