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

sfc: make capability checking a nic_type function

Various MCDI functions (especially in filter handling) need to check the
datapath caps, but those live in nic_data (since they don't exist on
Siena). Decouple from ef10-specific data structures by adding check_caps
to the nic_type, to allow using these functions from non-ef10 drivers.

Also add a convenience macro efx_has_cap() to reduce the amount of
boilerplate involved in calling it.

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

authored by

Tom Zhao and committed by
David S. Miller
be904b85 dfcabb07

+40
+18
drivers/net/ethernet/sfc/ef10.c
··· 3961 3961 return rc; 3962 3962 } 3963 3963 3964 + static unsigned int ef10_check_caps(const struct efx_nic *efx, 3965 + u8 flag, 3966 + u32 offset) 3967 + { 3968 + const struct efx_ef10_nic_data *nic_data = efx->nic_data; 3969 + 3970 + switch (offset) { 3971 + case(MC_CMD_GET_CAPABILITIES_V4_OUT_FLAGS1_OFST): 3972 + return nic_data->datapath_caps & BIT_ULL(flag); 3973 + case(MC_CMD_GET_CAPABILITIES_V4_OUT_FLAGS2_OFST): 3974 + return nic_data->datapath_caps2 & BIT_ULL(flag); 3975 + default: 3976 + return 0; 3977 + } 3978 + } 3979 + 3964 3980 #define EF10_OFFLOAD_FEATURES \ 3965 3981 (NETIF_F_IP_CSUM | \ 3966 3982 NETIF_F_HW_VLAN_CTAG_FILTER | \ ··· 4089 4073 .hwtstamp_filters = 1 << HWTSTAMP_FILTER_NONE | 4090 4074 1 << HWTSTAMP_FILTER_ALL, 4091 4075 .rx_hash_key_size = 40, 4076 + .check_caps = ef10_check_caps, 4092 4077 }; 4093 4078 4094 4079 const struct efx_nic_type efx_hunt_a0_nic_type = { ··· 4225 4208 .hwtstamp_filters = 1 << HWTSTAMP_FILTER_NONE | 4226 4209 1 << HWTSTAMP_FILTER_ALL, 4227 4210 .rx_hash_key_size = 40, 4211 + .check_caps = ef10_check_caps, 4228 4212 };
+12
drivers/net/ethernet/sfc/mcdi.h
··· 326 326 #define MCDI_EVENT_FIELD(_ev, _field) \ 327 327 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) 328 328 329 + #define MCDI_CAPABILITY(field) \ 330 + MC_CMD_GET_CAPABILITIES_V4_OUT_ ## field ## _LBN 331 + 332 + #define MCDI_CAPABILITY_OFST(field) \ 333 + MC_CMD_GET_CAPABILITIES_V4_OUT_ ## field ## _OFST 334 + 335 + /* field is FLAGS1 or FLAGS2 */ 336 + #define efx_has_cap(efx, flag, field) \ 337 + efx->type->check_caps(efx, \ 338 + MCDI_CAPABILITY(flag), \ 339 + MCDI_CAPABILITY_OFST(field)) 340 + 329 341 void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len); 330 342 int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, 331 343 u16 *fw_subtype_list, u32 *capabilities);
+3
drivers/net/ethernet/sfc/net_driver.h
··· 1354 1354 void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol); 1355 1355 int (*set_wol)(struct efx_nic *efx, u32 type); 1356 1356 void (*resume_wol)(struct efx_nic *efx); 1357 + unsigned int (*check_caps)(const struct efx_nic *efx, 1358 + u8 flag, 1359 + u32 offset); 1357 1360 int (*test_chip)(struct efx_nic *efx, struct efx_self_tests *tests); 1358 1361 int (*test_nvram)(struct efx_nic *efx); 1359 1362 void (*mcdi_request)(struct efx_nic *efx,
+7
drivers/net/ethernet/sfc/siena.c
··· 948 948 949 949 #endif /* CONFIG_SFC_MTD */ 950 950 951 + unsigned int siena_check_caps(const struct efx_nic *efx, 952 + u8 flag, u32 offset) 953 + { 954 + /* Siena did not support MC_CMD_GET_CAPABILITIES */ 955 + return 0; 956 + } 957 + 951 958 /************************************************************************** 952 959 * 953 960 * Revision-dependent attributes used by efx.c and nic.c