Skip to content

Commit be904b8

Browse files
tomz-xilinxdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dfcabb0 commit be904b8

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

drivers/net/ethernet/sfc/ef10.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3961,6 +3961,22 @@ static int efx_ef10_udp_tnl_del_port(struct efx_nic *efx,
39613961
return rc;
39623962
}
39633963

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+
39643980
#define EF10_OFFLOAD_FEATURES \
39653981
(NETIF_F_IP_CSUM | \
39663982
NETIF_F_HW_VLAN_CTAG_FILTER | \
@@ -4073,6 +4089,7 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
40734089
.hwtstamp_filters = 1 << HWTSTAMP_FILTER_NONE |
40744090
1 << HWTSTAMP_FILTER_ALL,
40754091
.rx_hash_key_size = 40,
4092+
.check_caps = ef10_check_caps,
40764093
};
40774094

40784095
const struct efx_nic_type efx_hunt_a0_nic_type = {
@@ -4208,4 +4225,5 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
42084225
.hwtstamp_filters = 1 << HWTSTAMP_FILTER_NONE |
42094226
1 << HWTSTAMP_FILTER_ALL,
42104227
.rx_hash_key_size = 40,
4228+
.check_caps = ef10_check_caps,
42114229
};

drivers/net/ethernet/sfc/mcdi.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,18 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev);
326326
#define MCDI_EVENT_FIELD(_ev, _field) \
327327
EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field)
328328

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+
329341
void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len);
330342
int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
331343
u16 *fw_subtype_list, u32 *capabilities);

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,9 @@ struct efx_nic_type {
13541354
void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol);
13551355
int (*set_wol)(struct efx_nic *efx, u32 type);
13561356
void (*resume_wol)(struct efx_nic *efx);
1357+
unsigned int (*check_caps)(const struct efx_nic *efx,
1358+
u8 flag,
1359+
u32 offset);
13571360
int (*test_chip)(struct efx_nic *efx, struct efx_self_tests *tests);
13581361
int (*test_nvram)(struct efx_nic *efx);
13591362
void (*mcdi_request)(struct efx_nic *efx,

drivers/net/ethernet/sfc/siena.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,13 @@ static int siena_mtd_probe(struct efx_nic *efx)
948948

949949
#endif /* CONFIG_SFC_MTD */
950950

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+
951958
/**************************************************************************
952959
*
953960
* Revision-dependent attributes used by efx.c and nic.c

0 commit comments

Comments
 (0)