49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Copyright (c) 2009-2015 Solarflare Communications Inc.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * All rights reserved.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Redistribution and use in source and binary forms, with or without
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * modification, are permitted provided that the following conditions are met:
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 1. Redistributions of source code must retain the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 2. Redistributions in binary form must reproduce the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer in the documentation
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * and/or other materials provided with the distribution.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * The views and conclusions contained in the software and documentation are
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * those of the authors and should not be interpreted as representing official
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * policies, either expressed or implied, of the FreeBSD Project.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_WOL));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (~(encp->enc_features) & EFX_FEATURE_WOL) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Current implementation is Siena specific */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_SIENA);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_WOL_FILTER_RESET_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_WOL);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_WOL_FILTER_RESET_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_WOL_FILTER_RESET_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_RESET_IN_MASK,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MC_CMD_WOL_FILTER_RESET_IN_LIGHTSOUT_OFFLOADS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_WOL_FILTER_SET_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_WOL);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_WOL_FILTER_SET_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_WOL_FILTER_SET_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_SET_IN_FILTER_MODE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_SET_IN_WOL_TYPE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN2(req, uint8_t, WOL_FILTER_SET_IN_MAGIC_MAC),
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_SET_IN_FILTER_MODE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_SET_IN_WOL_TYPE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * MC bitmask is supposed to be bit swapped
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * amongst 32 bit words(!)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(EFX_WOL_BITMAP_MASK_SIZE % 4, ==, 0);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore for (pos = 0; pos < EFX_WOL_BITMAP_MASK_SIZE; ++pos) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t native = paramp->ewp_bitmap.mask[pos];
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(paramp->ewp_bitmap.value_len, <=,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_SET_IN_BITMAP_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_SET_IN_FILTER_MODE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_SET_IN_WOL_TYPE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_SET_BYTE_FIELD(link_mask, MC_CMD_WOL_FILTER_SET_IN_LINK_UP,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_BYTE(req, WOL_FILTER_SET_IN_LINK_MASK,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_WOL_FILTER_SET_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *filter_idp = MCDI_OUT_DWORD(req, WOL_FILTER_SET_OUT_FILTER_ID);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_WOL_FILTER_REMOVE_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_WOL);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_WOL_FILTER_REMOVE_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_WOL_FILTER_REMOVE_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, WOL_FILTER_REMOVE_IN_FILTER_ID, filter_id);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MAX(MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_WOL);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, ADD_LIGHTSOUT_OFFLOAD_IN_ARP_IP,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore paramp->elop_ns.ip, sizeof (paramp->elop_ns.ip));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *filter_idp = MCDI_OUT_DWORD(req, ADD_LIGHTSOUT_OFFLOAD_OUT_FILTER_ID);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_WOL);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_cmd = MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, REMOVE_LIGHTSOUT_OFFLOAD_IN_PROTOCOL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, REMOVE_LIGHTSOUT_OFFLOAD_IN_PROTOCOL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, REMOVE_LIGHTSOUT_OFFLOAD_IN_FILTER_ID,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_WOL);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_WOL */