Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: move vport_id to struct efx_nic

Remove some usage of ef10-specific nic_data structs from common MCDI
functions, in preparation for using them from a non-EF10 driver.

Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Edward Cree and committed by
David S. Miller
dfcabb07 a90f704a

+29 -38
+8 -8
drivers/net/ethernet/sfc/ef10.c
··· 553 553 554 554 efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID; 555 555 556 - nic_data->vport_id = EVB_PORT_ID_ASSIGNED; 556 + efx->vport_id = EVB_PORT_ID_ASSIGNED; 557 557 558 558 /* In case we're recovering from a crash (kexec), we want to 559 559 * cancel any outstanding request by the previous user of this ··· 1335 1335 1336 1336 /* Driver-created vswitches and vports must be re-created */ 1337 1337 nic_data->must_probe_vswitching = true; 1338 - nic_data->vport_id = EVB_PORT_ID_ASSIGNED; 1338 + efx->vport_id = EVB_PORT_ID_ASSIGNED; 1339 1339 #ifdef CONFIG_SFC_SRIOV 1340 1340 if (nic_data->vf) 1341 1341 for (i = 0; i < efx->vf_count; i++) ··· 3158 3158 efx_mcdi_filter_table_remove(efx); 3159 3159 up_write(&efx->filter_sem); 3160 3160 3161 - rc = efx_ef10_vadaptor_free(efx, nic_data->vport_id); 3161 + rc = efx_ef10_vadaptor_free(efx, efx->vport_id); 3162 3162 if (rc) 3163 3163 goto restore_filters; 3164 3164 3165 3165 ether_addr_copy(mac_old, nic_data->vport_mac); 3166 - rc = efx_ef10_vport_del_mac(efx, nic_data->vport_id, 3166 + rc = efx_ef10_vport_del_mac(efx, efx->vport_id, 3167 3167 nic_data->vport_mac); 3168 3168 if (rc) 3169 3169 goto restore_vadaptor; 3170 3170 3171 - rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id, 3171 + rc = efx_ef10_vport_add_mac(efx, efx->vport_id, 3172 3172 efx->net_dev->dev_addr); 3173 3173 if (!rc) { 3174 3174 ether_addr_copy(nic_data->vport_mac, efx->net_dev->dev_addr); 3175 3175 } else { 3176 - rc2 = efx_ef10_vport_add_mac(efx, nic_data->vport_id, mac_old); 3176 + rc2 = efx_ef10_vport_add_mac(efx, efx->vport_id, mac_old); 3177 3177 if (rc2) { 3178 3178 /* Failed to add original MAC, so clear vport_mac */ 3179 3179 eth_zero_addr(nic_data->vport_mac); ··· 3182 3182 } 3183 3183 3184 3184 restore_vadaptor: 3185 - rc2 = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id); 3185 + rc2 = efx_ef10_vadaptor_alloc(efx, efx->vport_id); 3186 3186 if (rc2) 3187 3187 goto reset_nic; 3188 3188 restore_filters: ··· 3225 3225 ether_addr_copy(MCDI_PTR(inbuf, VADAPTOR_SET_MAC_IN_MACADDR), 3226 3226 efx->net_dev->dev_addr); 3227 3227 MCDI_SET_DWORD(inbuf, VADAPTOR_SET_MAC_IN_UPSTREAM_PORT_ID, 3228 - nic_data->vport_id); 3228 + efx->vport_id); 3229 3229 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VADAPTOR_SET_MAC, inbuf, 3230 3230 sizeof(inbuf), NULL, 0, NULL); 3231 3231
+13 -14
drivers/net/ethernet/sfc/ef10_sriov.c
··· 232 232 233 233 static int efx_ef10_vadaptor_alloc_set_features(struct efx_nic *efx) 234 234 { 235 - struct efx_ef10_nic_data *nic_data = efx->nic_data; 236 235 u32 port_flags; 237 236 int rc; 238 237 239 - rc = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id); 238 + rc = efx_ef10_vadaptor_alloc(efx, efx->vport_id); 240 239 if (rc) 241 240 goto fail_vadaptor_alloc; 242 241 243 - rc = efx_ef10_vadaptor_query(efx, nic_data->vport_id, 242 + rc = efx_ef10_vadaptor_query(efx, efx->vport_id, 244 243 &port_flags, NULL, NULL); 245 244 if (rc) 246 245 goto fail_vadaptor_query; ··· 280 281 281 282 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, 282 283 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL, 283 - EFX_EF10_NO_VLAN, &nic_data->vport_id); 284 + EFX_EF10_NO_VLAN, &efx->vport_id); 284 285 if (rc) 285 286 goto fail2; 286 287 287 - rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id, net_dev->dev_addr); 288 + rc = efx_ef10_vport_add_mac(efx, efx->vport_id, net_dev->dev_addr); 288 289 if (rc) 289 290 goto fail3; 290 291 ether_addr_copy(nic_data->vport_mac, net_dev->dev_addr); ··· 295 296 296 297 return 0; 297 298 fail4: 298 - efx_ef10_vport_del_mac(efx, nic_data->vport_id, nic_data->vport_mac); 299 + efx_ef10_vport_del_mac(efx, efx->vport_id, nic_data->vport_mac); 299 300 eth_zero_addr(nic_data->vport_mac); 300 301 fail3: 301 - efx_ef10_vport_free(efx, nic_data->vport_id); 302 - nic_data->vport_id = EVB_PORT_ID_ASSIGNED; 302 + efx_ef10_vport_free(efx, efx->vport_id); 303 + efx->vport_id = EVB_PORT_ID_ASSIGNED; 303 304 fail2: 304 305 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED); 305 306 fail1: ··· 354 355 355 356 efx_ef10_sriov_free_vf_vswitching(efx); 356 357 357 - efx_ef10_vadaptor_free(efx, nic_data->vport_id); 358 + efx_ef10_vadaptor_free(efx, efx->vport_id); 358 359 359 - if (nic_data->vport_id == EVB_PORT_ID_ASSIGNED) 360 + if (efx->vport_id == EVB_PORT_ID_ASSIGNED) 360 361 return; /* No vswitch was ever created */ 361 362 362 363 if (!is_zero_ether_addr(nic_data->vport_mac)) { 363 - efx_ef10_vport_del_mac(efx, nic_data->vport_id, 364 + efx_ef10_vport_del_mac(efx, efx->vport_id, 364 365 efx->net_dev->dev_addr); 365 366 eth_zero_addr(nic_data->vport_mac); 366 367 } 367 - efx_ef10_vport_free(efx, nic_data->vport_id); 368 - nic_data->vport_id = EVB_PORT_ID_ASSIGNED; 368 + efx_ef10_vport_free(efx, efx->vport_id); 369 + efx->vport_id = EVB_PORT_ID_ASSIGNED; 369 370 370 371 /* Only free the vswitch if no VFs are assigned */ 371 372 if (!pci_vfs_assigned(efx->pci_dev)) 372 - efx_ef10_vswitch_free(efx, nic_data->vport_id); 373 + efx_ef10_vswitch_free(efx, efx->vport_id); 373 374 } 374 375 375 376 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx)
+2 -3
drivers/net/ethernet/sfc/mcdi_filters.c
··· 186 186 struct efx_rss_context *ctx, 187 187 bool replacing) 188 188 { 189 - struct efx_ef10_nic_data *nic_data = efx->nic_data; 190 189 u32 flags = spec->flags; 191 190 192 191 memset(inbuf, 0, MC_CMD_FILTER_OP_EXT_IN_LEN); ··· 210 211 efx_mcdi_filter_push_prep_set_match_fields(efx, spec, inbuf); 211 212 } 212 213 213 - MCDI_SET_DWORD(inbuf, FILTER_OP_IN_PORT_ID, nic_data->vport_id); 214 + MCDI_SET_DWORD(inbuf, FILTER_OP_IN_PORT_ID, efx->vport_id); 214 215 MCDI_SET_DWORD(inbuf, FILTER_OP_IN_RX_DEST, 215 216 spec->dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP ? 216 217 MC_CMD_FILTER_OP_IN_RX_DEST_DROP : ··· 1943 1944 return -EOPNOTSUPP; 1944 1945 1945 1946 MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_UPSTREAM_PORT_ID, 1946 - nic_data->vport_id); 1947 + efx->vport_id); 1947 1948 MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_TYPE, alloc_type); 1948 1949 MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES, rss_spread); 1949 1950
+2 -6
drivers/net/ethernet/sfc/mcdi_functions.c
··· 168 168 size_t entries = tx_queue->txd.buf.len / EFX_BUF_SIZE; 169 169 struct efx_channel *channel = tx_queue->channel; 170 170 struct efx_nic *efx = tx_queue->efx; 171 - struct efx_ef10_nic_data *nic_data; 172 171 dma_addr_t dma_addr; 173 172 size_t inlen; 174 173 int rc, i; 175 174 176 175 BUILD_BUG_ON(MC_CMD_INIT_TXQ_OUT_LEN != 0); 177 176 178 - nic_data = efx->nic_data; 179 - 180 177 MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_SIZE, tx_queue->ptr_mask + 1); 181 178 MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_TARGET_EVQ, channel->channel); 182 179 MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_LABEL, tx_queue->queue); 183 180 MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_INSTANCE, tx_queue->queue); 184 181 MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_OWNER_ID, 0); 185 - MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_PORT_ID, nic_data->vport_id); 182 + MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_PORT_ID, efx->vport_id); 186 183 187 184 dma_addr = tx_queue->txd.buf.dma_addr; 188 185 ··· 273 276 struct efx_channel *channel = efx_rx_queue_channel(rx_queue); 274 277 size_t entries = rx_queue->rxd.buf.len / EFX_BUF_SIZE; 275 278 struct efx_nic *efx = rx_queue->efx; 276 - struct efx_ef10_nic_data *nic_data = efx->nic_data; 277 279 dma_addr_t dma_addr; 278 280 size_t inlen; 279 281 int rc; ··· 291 295 INIT_RXQ_IN_FLAG_PREFIX, 1, 292 296 INIT_RXQ_IN_FLAG_TIMESTAMP, 1); 293 297 MCDI_SET_DWORD(inbuf, INIT_RXQ_IN_OWNER_ID, 0); 294 - MCDI_SET_DWORD(inbuf, INIT_RXQ_IN_PORT_ID, nic_data->vport_id); 298 + MCDI_SET_DWORD(inbuf, INIT_RXQ_IN_PORT_ID, efx->vport_id); 295 299 296 300 dma_addr = rx_queue->rxd.buf.dma_addr; 297 301
+2 -5
drivers/net/ethernet/sfc/mcdi_port.c
··· 722 722 MAC_STATS_IN_PERIOD_MS, period); 723 723 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len); 724 724 725 - if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) { 726 - struct efx_ef10_nic_data *nic_data = efx->nic_data; 727 - 728 - MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id); 729 - } 725 + if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) 726 + MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, efx->vport_id); 730 727 731 728 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), 732 729 NULL, 0, NULL);
+2
drivers/net/ethernet/sfc/net_driver.h
··· 887 887 * @rss_context: Main RSS context. Its @list member is the head of the list of 888 888 * RSS contexts created by user requests 889 889 * @rss_lock: Protects custom RSS context software state in @rss_context.list 890 + * @vport_id: The function's vport ID, only relevant for PFs 890 891 * @int_error_count: Number of internal errors seen recently 891 892 * @int_error_expire: Time at which error count will be expired 892 893 * @irq_soft_enabled: Are IRQs soft-enabled? If not, IRQ handler will ··· 1045 1044 bool rx_scatter; 1046 1045 struct efx_rss_context rss_context; 1047 1046 struct mutex rss_lock; 1047 + u32 vport_id; 1048 1048 1049 1049 unsigned int_error_count; 1050 1050 unsigned long int_error_expire;
-2
drivers/net/ethernet/sfc/nic.h
··· 385 385 * %MC_CMD_GET_CAPABILITIES response) 386 386 * @rx_dpcpu_fw_id: Firmware ID of the RxDPCPU 387 387 * @tx_dpcpu_fw_id: Firmware ID of the TxDPCPU 388 - * @vport_id: The function's vport ID, only relevant for PFs 389 388 * @must_probe_vswitching: Flag: vswitching has yet to be setup after MC reboot 390 389 * @pf_index: The number for this PF, or the parent PF if this is a VF 391 390 #ifdef CONFIG_SFC_SRIOV ··· 422 423 u32 datapath_caps2; 423 424 unsigned int rx_dpcpu_fw_id; 424 425 unsigned int tx_dpcpu_fw_id; 425 - unsigned int vport_id; 426 426 bool must_probe_vswitching; 427 427 unsigned int pf_index; 428 428 u8 port_id[ETH_ALEN];