7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Copyright (c) 2007-2015 Solarflare Communications Inc.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Redistribution and use in source and binary forms, with or without
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * modification, are permitted provided that the following conditions are met:
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * 1. Redistributions of source code must retain the above copyright notice,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * this list of conditions and the following disclaimer.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * 2. Redistributions in binary form must reproduce the above copyright notice,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * this list of conditions and the following disclaimer in the documentation
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and/or other materials provided with the distribution.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The views and conclusions contained in the software and documentation are
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * those of the authors and should not be interpreted as representing official
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * policies, either expressed or implied, of the FreeBSD Project.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define EFE_SPEC(eftp, index) ((eftp)->eft_entry[(index)].efe_spec)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (EFE_SPEC(eftp, index) & EFX_EF10_FILTER_FLAG_BUSY)
c40d7343efa60b18ad1ceb316eb337caeea79046cindi if (EFE_SPEC(eftp, index) & EFX_EF10_FILTER_FLAG_AUTO_OLD)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi EFE_SPEC(eftp, index) |= (uintptr_t)EFX_EF10_FILTER_FLAG_BUSY;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi EFE_SPEC(eftp, index) &= ~(uintptr_t)EFX_EF10_FILTER_FLAG_BUSY;
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh EFSYS_ASSERT(ef10_filter_entry_spec(eftp, index) != NULL);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi EFE_SPEC(eftp, index) |= (uintptr_t)EFX_EF10_FILTER_FLAG_AUTO_OLD;
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye EFE_SPEC(eftp, index) &= ~(uintptr_t)EFX_EF10_FILTER_FLAG_AUTO_OLD;
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye EFSYS_ASSERT(ef10_filter_entry_spec(eftp, index) != NULL);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define MATCH_MASK(match) (EFX_MASK32(match) << EFX_LOW_BIT(match))
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (ef10_filter_table_t), eftp);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (0);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi EFSYS_KMEM_FREE(enp->en_esip, sizeof (ef10_filter_table_t),
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* FALLTHROUGH */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (spec->efs_match_flags & EFX_FILTER_MATCH_LOC_MAC_IG) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * The LOC_MAC_IG match flag can represent unknown unicast
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * or multicast filters - use the MAC address to distinguish
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi match_fields |= spec->efs_match_flags & (~EFX_FILTER_MATCH_LOC_MAC_IG);
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye if (filter_op != MC_CMD_FILTER_OP_IN_OP_REPLACE) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * NOTE: Unlike most MCDI requests, the filter fields
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi * are presented in network (big endian) byte order.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi (void) memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_IN_SRC_MAC),
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi (void) memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_IN_DST_MAC),
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye /* IP protocol (in low byte, high byte is zero) */
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye EFX_STATIC_ASSERT(sizeof (spec->efs_rem_host) ==
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi (void) memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_IN_SRC_IP),
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi (void) memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_IN_DST_IP),
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (req.emr_out_length_used < MC_CMD_FILTER_OP_OUT_LEN) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi handle->efh_lo = MCDI_OUT_DWORD(req, FILTER_OP_OUT_HANDLE_LO);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi handle->efh_hi = MCDI_OUT_DWORD(req, FILTER_OP_OUT_HANDLE_HI);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
47911a7d5f24c2fc37e7b5bcc696fe32e750c16ccy MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_LO, handle->efh_lo);
47911a7d5f24c2fc37e7b5bcc696fe32e750c16ccy MCDI_IN_SET_DWORD(req, FILTER_OP_IN_HANDLE_HI, handle->efh_hi);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (req.emr_out_length_used < MC_CMD_FILTER_OP_OUT_LEN) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* FIXME: Consider rx vs tx filters (look at efs_flags) */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (!EFX_OWORD_IS_EQUAL(left->efs_rem_host, right->efs_rem_host))
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (!EFX_OWORD_IS_EQUAL(left->efs_loc_host, right->efs_loc_host))
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (memcmp(left->efs_rem_mac, right->efs_rem_mac, EFX_MAC_ADDR_LEN))
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (memcmp(left->efs_loc_mac, right->efs_loc_mac, EFX_MAC_ADDR_LEN))
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj } else if ((~(left->efs_flags) & EFX_FILTER_FLAG_RX_RSS) &&
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj EFX_STATIC_ASSERT((sizeof (efx_filter_spec_t) % sizeof (uint32_t))
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi EFX_STATIC_ASSERT((EFX_FIELD_OFFSET(efx_filter_spec_t, efs_outer_vid) %
c40d7343efa60b18ad1ceb316eb337caeea79046cindi sizeof (uint32_t)) == 0);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * As the area of the efx_filter_spec_t we need to hash is DWORD
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * aligned and an exact number of DWORDs in size we can use the
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * optimised efx_hash_dwords() rather than efx_hash_bytes()
c40d7343efa60b18ad1ceb316eb337caeea79046cindi return (efx_hash_dwords((const void *)&spec->efs_outer_vid,
c40d7343efa60b18ad1ceb316eb337caeea79046cindi sizeof (uint32_t), 0));
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Decide whether a filter should be exclusive or else should allow
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * delivery to additional recipients. Currently we decide that
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * filters for specific local unicast MAC and IP addresses are
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * exclusive.
c40d7343efa60b18ad1ceb316eb337caeea79046cindi if ((spec->efs_match_flags & EFX_FILTER_MATCH_LOC_MAC) &&
c40d7343efa60b18ad1ceb316eb337caeea79046cindi (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_LOC_HOST)) ==
c40d7343efa60b18ad1ceb316eb337caeea79046cindi (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_LOC_HOST)) {
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi for (tbl_id = 0; tbl_id < EFX_EF10_FILTER_TBL_ROWS; tbl_id++) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Ignore busy entries. */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * An arbitrary search limit for the software hash table. As per the linux net
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye unsigned int i;
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * FIXME: Add support for inserting filters of different priorities
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye * and removing lower priority multicast filters (bug 42378)
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * Find any existing filters with the same match tuple or
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * else a free slot to insert at. If any of them are busy,
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * we have to wait and retry.
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj for (;;) {
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj for (;;) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Leave existing */
12cc75c814f0c017004a9bbc96429911e008601bcindi * Once we reach the maximum search depth, use
12cc75c814f0c017004a9bbc96429911e008601bcindi * the first suitable slot or return EBUSY if
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * there was none.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Create a software table entry if necessary, and mark it
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * busy. We might yet fail to insert, but any attempt to
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * insert a conflicting filter while we're waiting for the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * firmware must find the busy entry.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (saved_spec->efs_priority == EFX_FILTER_PRI_AUTO) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* This is a filter we are refreshing */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*spec), saved_spec);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * On replacing the filter handle may change after after a successful
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * replace operation.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Update the fields that may differ */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), saved_spec);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi rc = ef10_filter_add_internal(enp, spec, may_replace, NULL);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi return (0);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint32_t filter_idx = filter_id % EFX_EF10_FILTER_TBL_ROWS;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Find the software table entry and mark it busy. Don't
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * remove it yet; any attempt to update while we're waiting
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * for the firmware must find the busy entry.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * FIXME: What if the busy flag is never cleared?
c40d7343efa60b18ad1ceb316eb337caeea79046cindi while (ef10_filter_entry_is_busy(table, filter_idx)) {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi if ((spec = ef10_filter_entry_spec(table, filter_idx)) != NULL) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Try to remove the hardware filter. This may fail if the MC has
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * rebooted (which frees all hardware filter resources).
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi /* Free the software table entry */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi /* Check result of hardware filter removal */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (0);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi unsigned int i;
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (saved_spec && ef10_filter_equal(spec, saved_spec) &&
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (0);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj uint8_t payload[MAX(MC_CMD_GET_PARSER_DISP_INFO_IN_LEN,
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj req.emr_in_length = MC_CMD_GET_PARSER_DISP_INFO_IN_LEN;
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj req.emr_out_length = MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX;
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj MC_CMD_GET_PARSER_DISP_INFO_IN_OP_GET_SUPPORTED_RX_MATCHES);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_LEN);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * Remove UNKNOWN UCAST and MCAST flags, and if both are present, change
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * the lower priority one to LOC_MAC_IG.
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj for (i = 0; i < *length; i++) {
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj if (list[i] & MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_UCAST_DST_LBN) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (list[i] & MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_MCAST_DST_LBN) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if ((rc = efx_mcdi_get_parser_disp_info(enp, list, length)) != 0)
1db96d3b343c9ab3090da5b745f1cd9de2f192efCheng Sean Ye ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye /* Insert the filter for the local station address */
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye (void) efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC,
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye &eftp->eft_unicst_filter_indexes[eftp->eft_unicst_filter_count]);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj return (0);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj /* Insert the unknown unicast filter */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi &eftp->eft_unicst_filter_indexes[eftp->eft_unicst_filter_count]);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Too many MAC addresses */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Insert/renew multicast address list filters */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi for (i = 0; i < count; i++) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (rc == 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi /* Only stop upon failure if told to rollback */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi /* Insert/renew broadcast address filter */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (rc == 0) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Only stop upon failure if told to rollback */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Remove any filters we have inserted */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi while (i--) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Insert the unknown multicast filter */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * FIXME: If brdcst == B_FALSE, add a filter to drop broadcast traffic.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
89c0ae934a35c2ab26de63e1d9fba6bcb04c6306cindi rc = efx_mcdi_get_workarounds(enp, &implemented, &enabled);
89c0ae934a35c2ab26de63e1d9fba6bcb04c6306cindi if (rc == 0) {
89c0ae934a35c2ab26de63e1d9fba6bcb04c6306cindi /* Check if chained multicast filter support is enabled */
89c0ae934a35c2ab26de63e1d9fba6bcb04c6306cindi if (implemented & enabled & MC_CMD_GET_WORKAROUNDS_OUT_BUG26807)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Firmware is too old to support GET_WORKAROUNDS, and support
89c0ae934a35c2ab26de63e1d9fba6bcb04c6306cindi * for this workaround was implemented later.
89c0ae934a35c2ab26de63e1d9fba6bcb04c6306cindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Reconfigure all filters.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If all_unicst and/or all mulcst filters cannot be applied then
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * return ENOTSUP (Note the filters for the specified addresses are
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * still applied in this case).
940d71d237794874e18a0eb72f6564821a823517eschrock ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
940d71d237794874e18a0eb72f6564821a823517eschrock unsigned i;
940d71d237794874e18a0eb72f6564821a823517eschrock * Filters direct traffic to the default RXQ, and so cannot be
940d71d237794874e18a0eb72f6564821a823517eschrock * inserted until it is available. Any currently configured
940d71d237794874e18a0eb72f6564821a823517eschrock * filters must be removed (ignore errors in case the MC
940d71d237794874e18a0eb72f6564821a823517eschrock * has rebooted, which removes hardware filters).
940d71d237794874e18a0eb72f6564821a823517eschrock for (i = 0; i < table->eft_unicst_filter_count; i++) {
940d71d237794874e18a0eb72f6564821a823517eschrock for (i = 0; i < table->eft_mulcst_filter_count; i++) {
940d71d237794874e18a0eb72f6564821a823517eschrock return (0);
940d71d237794874e18a0eb72f6564821a823517eschrock /* Mark old filters which may need to be removed */
940d71d237794874e18a0eb72f6564821a823517eschrock for (i = 0; i < table->eft_unicst_filter_count; i++) {
940d71d237794874e18a0eb72f6564821a823517eschrock for (i = 0; i < table->eft_mulcst_filter_count; i++) {
940d71d237794874e18a0eb72f6564821a823517eschrock * Insert or renew unicast filters.
940d71d237794874e18a0eb72f6564821a823517eschrock * Frimware does not perform chaining on unicast filters. As traffic is
940d71d237794874e18a0eb72f6564821a823517eschrock * therefore only delivered to the first matching filter, we should
940d71d237794874e18a0eb72f6564821a823517eschrock * always insert the specific filter for our MAC address, to try and
940d71d237794874e18a0eb72f6564821a823517eschrock * ensure we get that traffic.
940d71d237794874e18a0eb72f6564821a823517eschrock * (If the filter for our MAC address has already been inserted by
940d71d237794874e18a0eb72f6564821a823517eschrock * another function, we won't receive traffic sent to us, even if we
940d71d237794874e18a0eb72f6564821a823517eschrock * insert a unicast mismatch filter. To prevent traffic stealing, this
940d71d237794874e18a0eb72f6564821a823517eschrock * therefore relies on the privilege model only allowing functions to
940d71d237794874e18a0eb72f6564821a823517eschrock * insert filters for their own MAC address unless explicitly given
940d71d237794874e18a0eb72f6564821a823517eschrock * additional privileges by the user. This also means that, even on a
940d71d237794874e18a0eb72f6564821a823517eschrock * priviliged function, inserting a unicast mismatch filter may not
940d71d237794874e18a0eb72f6564821a823517eschrock * catch all traffic in multi PCI function scenarios.)
940d71d237794874e18a0eb72f6564821a823517eschrock rc = ef10_filter_insert_unicast(enp, mac_addr, filter_flags);
940d71d237794874e18a0eb72f6564821a823517eschrock all_unicst_rc = ef10_filter_insert_all_unicast(enp,
940d71d237794874e18a0eb72f6564821a823517eschrock * WORKAROUND_BUG26807 controls firmware support for chained multicast
940d71d237794874e18a0eb72f6564821a823517eschrock * filters, and can only be enabled or disabled when the hardware filter
940d71d237794874e18a0eb72f6564821a823517eschrock * table is empty.
940d71d237794874e18a0eb72f6564821a823517eschrock * Chained multicast filters require support from the datapath firmware,
940d71d237794874e18a0eb72f6564821a823517eschrock * and may not be available (e.g. low-latency variants or old Huntington
940d71d237794874e18a0eb72f6564821a823517eschrock * firmware).
940d71d237794874e18a0eb72f6564821a823517eschrock * Firmware will reset (FLR) functions which have inserted filters in
940d71d237794874e18a0eb72f6564821a823517eschrock * the hardware filter table when the workaround is enabled/disabled.
940d71d237794874e18a0eb72f6564821a823517eschrock * Functions without any hardware filters are not reset.
940d71d237794874e18a0eb72f6564821a823517eschrock * Re-check if the workaround is enabled after adding unicast hardware
940d71d237794874e18a0eb72f6564821a823517eschrock * filters. This ensures that encp->enc_bug26807_workaround matches the
940d71d237794874e18a0eb72f6564821a823517eschrock * firmware state, and that later changes to enable/disable the
940d71d237794874e18a0eb72f6564821a823517eschrock * workaround will result in this function seeing a reset (FLR).
940d71d237794874e18a0eb72f6564821a823517eschrock * In common-code drivers, we only support multiple PCI function
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * scenarios with firmware that supports multicast chaining, so we can
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * assume it is enabled for such cases and hence simplify the filter
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * insertion logic. Firmware that does not support multicast chaining
78432d5ed5122db8b0bbfa41e00d063bf8ae7171cy * does not support multiple PCI function configurations either, so
78432d5ed5122db8b0bbfa41e00d063bf8ae7171cy * filter insertion is much simpler and the same strategies can still be
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Multicast filter chaining is enabled, so traffic that matches
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * more than one multicast filter will be replicated and
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * delivered to multiple recipients. To avoid this duplicate
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * delivery, remove old multicast filters before inserting new
940d71d237794874e18a0eb72f6564821a823517eschrock * multicast filters.
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj /* Insert or renew multicast filters */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * Insert the all multicast filter. If that fails, try to insert
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * all of our multicast filters (but without rollback on
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * failure).
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Insert filters for multicast addresses.
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * If any insertion fails, then rollback and try to insert the
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * all multicast filter instead.
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * If that also fails, try to insert all of the multicast
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * filters (but without rollback on failure).
c40d7343efa60b18ad1ceb316eb337caeea79046cindi rc = ef10_filter_insert_multicast_list(enp, mulcst, brdcst,
01e689ccb14727455003b77ee332005223497875cindi if (rc != 0) {
940d71d237794874e18a0eb72f6564821a823517eschrock * Multicast filter chaining is on, so remove
940d71d237794874e18a0eb72f6564821a823517eschrock * old filters before inserting the multicast
01e689ccb14727455003b77ee332005223497875cindi * all filter to avoid duplicate delivery caused
940d71d237794874e18a0eb72f6564821a823517eschrock * by packets matching multiple filters.
c40d7343efa60b18ad1ceb316eb337caeea79046cindi if (rc != 0) {
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj /* Remove old filters which were not renewed */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj /* report if any optional flags were rejected */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj if (((all_unicst != B_FALSE) && (all_unicst_rc != 0)) ||
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj /* Clear auto old flags */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj#endif /* EFSYS_OPT_FILTER */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */