From daa007afd04b40f903b02035b73c945b4a25efff Mon Sep 17 00:00:00 2001 From: Mark Spender Date: Thu, 9 Mar 2017 15:26:23 +0000 Subject: [PATCH] net/sfc/base: split local MAC I/G back into separate flags The flag EFX_FILTER_MATCH_LOC_MAC_IG to represent filtering on the individual/group bit of the MAC address (with the two cases being distinguished by the MAC address in the filter specification) was introduced to mirror the Linux driver filtering code, but the implementations are different enough anyway that it isn't of much value. Having separate flags for unknown unicast and multicast simplifies the code and allows the set of flags to match those used by MCDI. It will also makes it easier to report whether these filters are supported. In the MCDI definitions, the unknown multicast and unicast flags have the values 0x40000000 and 0x80000000 respectively, and so using the same values for simplicity requires 32 bits in the filter specification to store the flags. This means the structure is now a little bigger than 64 bytes, but filters are not often used on critical paths so this shouldn't have much impact - on Linux they are also bigger than they used to be. Signed-off-by: Mark Spender Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/base/ef10_filter.c | 48 ++++-------------------------- drivers/net/sfc/base/efx.h | 10 +++---- drivers/net/sfc/base/efx_filter.c | 8 ++--- 3 files changed, 12 insertions(+), 54 deletions(-) diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/net/sfc/base/ef10_filter.c index c161977a5d..f5201479fa 100644 --- a/drivers/net/sfc/base/ef10_filter.c +++ b/drivers/net/sfc/base/ef10_filter.c @@ -142,6 +142,10 @@ ef10_filter_init( MATCH_MASK(MC_CMD_FILTER_OP_IN_MATCH_OUTER_VLAN)); EFX_STATIC_ASSERT(EFX_FILTER_MATCH_IP_PROTO == MATCH_MASK(MC_CMD_FILTER_OP_IN_MATCH_IP_PROTO)); + EFX_STATIC_ASSERT(EFX_FILTER_MATCH_UNKNOWN_MCAST_DST == + MATCH_MASK(MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_MCAST_DST)); + EFX_STATIC_ASSERT((uint32_t)EFX_FILTER_MATCH_UNKNOWN_UCAST_DST == + MATCH_MASK(MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_UCAST_DST)); #undef MATCH_MASK EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (ef10_filter_table_t), eftp); @@ -184,7 +188,6 @@ efx_mcdi_filter_op_add( efx_mcdi_req_t req; uint8_t payload[MAX(MC_CMD_FILTER_OP_IN_LEN, MC_CMD_FILTER_OP_OUT_LEN)]; - uint32_t match_fields = 0; efx_rc_t rc; memset(payload, 0, sizeof (payload)); @@ -211,26 +214,10 @@ efx_mcdi_filter_op_add( goto fail1; } - if (spec->efs_match_flags & EFX_FILTER_MATCH_LOC_MAC_IG) { - /* - * The LOC_MAC_IG match flag can represent unknown unicast - * or multicast filters - use the MAC address to distinguish - * them. - */ - if (EFX_MAC_ADDR_IS_MULTICAST(spec->efs_loc_mac)) - match_fields |= 1U << - MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_MCAST_DST_LBN; - else - match_fields |= 1U << - MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_UCAST_DST_LBN; - } - - match_fields |= spec->efs_match_flags & (~EFX_FILTER_MATCH_LOC_MAC_IG); - MCDI_IN_SET_DWORD(req, FILTER_OP_IN_PORT_ID, EVB_PORT_ID_ASSIGNED); MCDI_IN_SET_DWORD(req, FILTER_OP_IN_MATCH_FIELDS, - match_fields); + spec->efs_match_flags); MCDI_IN_SET_DWORD(req, FILTER_OP_IN_RX_DEST, MC_CMD_FILTER_OP_IN_RX_DEST_HOST); MCDI_IN_SET_DWORD(req, FILTER_OP_IN_RX_QUEUE, @@ -889,9 +876,6 @@ efx_mcdi_get_parser_disp_info( uint8_t payload[MAX(MC_CMD_GET_PARSER_DISP_INFO_IN_LEN, MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX)]; efx_rc_t rc; - uint32_t i; - boolean_t support_unknown_ucast = B_FALSE; - boolean_t support_unknown_mcast = B_FALSE; (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_GET_PARSER_DISP_INFO; @@ -927,28 +911,6 @@ efx_mcdi_get_parser_disp_info( EFX_STATIC_ASSERT(sizeof (uint32_t) == MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_LEN); - /* - * Remove UNKNOWN UCAST and MCAST flags, and if both are present, change - * the lower priority one to LOC_MAC_IG. - */ - for (i = 0; i < *length; i++) { - if (list[i] & MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_UCAST_DST_LBN) { - list[i] &= - (~MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_UCAST_DST_LBN); - support_unknown_ucast = B_TRUE; - } - if (list[i] & MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_MCAST_DST_LBN) { - list[i] &= - (~MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_MCAST_DST_LBN); - support_unknown_mcast = B_TRUE; - } - - if (support_unknown_ucast && support_unknown_mcast) { - list[i] &= EFX_FILTER_MATCH_LOC_MAC_IG; - break; - } - } - return (0); fail2: diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h index 7c2fab71d9..43157e2622 100644 --- a/drivers/net/sfc/base/efx.h +++ b/drivers/net/sfc/base/efx.h @@ -2228,10 +2228,10 @@ typedef enum efx_filter_match_flags_e { EFX_FILTER_MATCH_OUTER_VID = 0x0100, /* Match by outer VLAN ID */ EFX_FILTER_MATCH_IP_PROTO = 0x0200, /* Match by IP transport * protocol */ - EFX_FILTER_MATCH_LOC_MAC_IG = 0x0400, /* Match by local MAC address - * I/G bit. Used for RX default - * unicast and multicast/ - * broadcast filters. */ + /* Match otherwise-unmatched multicast and broadcast packets */ + EFX_FILTER_MATCH_UNKNOWN_MCAST_DST = 0x40000000, + /* Match otherwise-unmatched unicast packets */ + EFX_FILTER_MATCH_UNKNOWN_UCAST_DST = 0x80000000, } efx_filter_match_flags_t; typedef enum efx_filter_priority_s { @@ -2253,7 +2253,7 @@ typedef enum efx_filter_priority_s { */ typedef struct efx_filter_spec_s { - uint32_t efs_match_flags:12; + uint32_t efs_match_flags; uint32_t efs_priority:2; uint32_t efs_flags:6; uint32_t efs_dmaq_id:12; diff --git a/drivers/net/sfc/base/efx_filter.c b/drivers/net/sfc/base/efx_filter.c index a20efaf96b..4f58a7d6f0 100644 --- a/drivers/net/sfc/base/efx_filter.c +++ b/drivers/net/sfc/base/efx_filter.c @@ -149,9 +149,6 @@ efx_filter_init( const efx_filter_ops_t *efop; efx_rc_t rc; - /* Check that efx_filter_spec_t is 64 bytes. */ - EFX_STATIC_ASSERT(sizeof (efx_filter_spec_t) == 64); - EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_FILTER)); @@ -387,7 +384,7 @@ efx_filter_spec_set_uc_def( { EFSYS_ASSERT3P(spec, !=, NULL); - spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG; + spec->efs_match_flags |= EFX_FILTER_MATCH_UNKNOWN_UCAST_DST; return (0); } @@ -400,8 +397,7 @@ efx_filter_spec_set_mc_def( { EFSYS_ASSERT3P(spec, !=, NULL); - spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG; - spec->efs_loc_mac[0] = 1; + spec->efs_match_flags |= EFX_FILTER_MATCH_UNKNOWN_MCAST_DST; return (0); } -- 2.20.1