2 * Copyright (c) 2009-2016 Solarflare Communications Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
36 __checkReturn efx_rc_t
39 __out efx_link_mode_t *link_modep)
41 efx_port_t *epp = &(enp->en_port);
42 siena_link_state_t sls;
45 if ((rc = siena_phy_get_link(enp, &sls)) != 0)
48 epp->ep_adv_cap_mask = sls.sls_adv_cap_mask;
49 epp->ep_fcntl = sls.sls_fcntl;
51 *link_modep = sls.sls_link_mode;
56 EFSYS_PROBE1(fail1, efx_rc_t, rc);
58 *link_modep = EFX_LINK_UNKNOWN;
63 __checkReturn efx_rc_t
66 __out boolean_t *mac_upp)
68 siena_link_state_t sls;
72 * Because Siena doesn't *require* polling, we can't rely on
73 * siena_mac_poll() being executed to populate epp->ep_mac_up.
75 if ((rc = siena_phy_get_link(enp, &sls)) != 0)
78 *mac_upp = sls.sls_mac_up;
83 EFSYS_PROBE1(fail1, efx_rc_t, rc);
88 __checkReturn efx_rc_t
89 siena_mac_reconfigure(
92 efx_port_t *epp = &(enp->en_port);
93 efx_oword_t multicast_hash[2];
95 uint8_t payload[MAX(MAX(MC_CMD_SET_MAC_IN_LEN,
96 MC_CMD_SET_MAC_OUT_LEN),
97 MAX(MC_CMD_SET_MCAST_HASH_IN_LEN,
98 MC_CMD_SET_MCAST_HASH_OUT_LEN))];
102 (void) memset(payload, 0, sizeof (payload));
103 req.emr_cmd = MC_CMD_SET_MAC;
104 req.emr_in_buf = payload;
105 req.emr_in_length = MC_CMD_SET_MAC_IN_LEN;
106 req.emr_out_buf = payload;
107 req.emr_out_length = MC_CMD_SET_MAC_OUT_LEN;
109 MCDI_IN_SET_DWORD(req, SET_MAC_IN_MTU, epp->ep_mac_pdu);
110 MCDI_IN_SET_DWORD(req, SET_MAC_IN_DRAIN, epp->ep_mac_drain ? 1 : 0);
111 EFX_MAC_ADDR_COPY(MCDI_IN2(req, uint8_t, SET_MAC_IN_ADDR),
113 MCDI_IN_POPULATE_DWORD_2(req, SET_MAC_IN_REJECT,
114 SET_MAC_IN_REJECT_UNCST, !epp->ep_all_unicst,
115 SET_MAC_IN_REJECT_BRDCST, !epp->ep_brdcst);
117 if (epp->ep_fcntl_autoneg)
118 /* efx_fcntl_set() has already set the phy capabilities */
119 fcntl = MC_CMD_FCNTL_AUTO;
120 else if (epp->ep_fcntl & EFX_FCNTL_RESPOND)
121 fcntl = (epp->ep_fcntl & EFX_FCNTL_GENERATE)
123 : MC_CMD_FCNTL_RESPOND;
125 fcntl = MC_CMD_FCNTL_OFF;
127 MCDI_IN_SET_DWORD(req, SET_MAC_IN_FCNTL, fcntl);
129 efx_mcdi_execute(enp, &req);
131 if (req.emr_rc != 0) {
136 /* Push multicast hash */
138 if (epp->ep_all_mulcst) {
139 /* A hash matching all multicast is all 1s */
140 EFX_SET_OWORD(multicast_hash[0]);
141 EFX_SET_OWORD(multicast_hash[1]);
142 } else if (epp->ep_mulcst) {
143 /* Use the hash set by the multicast list */
144 multicast_hash[0] = epp->ep_multicst_hash[0];
145 multicast_hash[1] = epp->ep_multicst_hash[1];
147 /* A hash matching no traffic is simply 0 */
148 EFX_ZERO_OWORD(multicast_hash[0]);
149 EFX_ZERO_OWORD(multicast_hash[1]);
153 * Broadcast packets go through the multicast hash filter.
154 * The IEEE 802.3 CRC32 of the broadcast address is 0xbe2612ff
155 * so we always add bit 0xff to the mask (bit 0x7f in the
158 if (epp->ep_brdcst) {
160 * NOTE: due to constant folding, some of this evaluates
161 * to null expressions, giving E_EXPR_NULL_EFFECT during
162 * lint on Illumos. No good way to fix this without
163 * explicit coding the individual word/bit setting.
164 * So just suppress lint for this one line.
167 EFX_SET_OWORD_BIT(multicast_hash[1], 0x7f);
170 (void) memset(payload, 0, sizeof (payload));
171 req.emr_cmd = MC_CMD_SET_MCAST_HASH;
172 req.emr_in_buf = payload;
173 req.emr_in_length = MC_CMD_SET_MCAST_HASH_IN_LEN;
174 req.emr_out_buf = payload;
175 req.emr_out_length = MC_CMD_SET_MCAST_HASH_OUT_LEN;
177 memcpy(MCDI_IN2(req, uint8_t, SET_MCAST_HASH_IN_HASH0),
178 multicast_hash, sizeof (multicast_hash));
180 efx_mcdi_execute(enp, &req);
182 if (req.emr_rc != 0) {
192 EFSYS_PROBE1(fail1, efx_rc_t, rc);
197 __checkReturn efx_rc_t
205 #endif /* EFSYS_OPT_SIENA */