Deleted Added
full compact
sfxge_port.c (277890) sfxge_port.c (278221)
1/*-
2 * Copyright (c) 2010-2011 Solarflare Communications, Inc.
3 * All rights reserved.
4 *
5 * This software was developed in part by Philip Paeps under contract for
6 * Solarflare Communications, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010-2011 Solarflare Communications, Inc.
3 * All rights reserved.
4 *
5 * This software was developed in part by Philip Paeps under contract for
6 * Solarflare Communications, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/sfxge/sfxge_port.c 277890 2015-01-29 19:02:25Z arybchik $");
31__FBSDID("$FreeBSD: head/sys/dev/sfxge/sfxge_port.c 278221 2015-02-04 20:03:57Z arybchik $");
32
33#include <sys/types.h>
34#include <sys/limits.h>
35#include <net/ethernet.h>
36#include <net/if_dl.h>
37
38#include "common/efx.h"
39
40#include "sfxge.h"
41
42static int
43sfxge_mac_stat_update(struct sfxge_softc *sc)
44{
45 struct sfxge_port *port = &sc->port;
46 efsys_mem_t *esmp = &(port->mac_stats.dma_buf);
47 clock_t now;
48 unsigned int count;
49 int rc;
50
32
33#include <sys/types.h>
34#include <sys/limits.h>
35#include <net/ethernet.h>
36#include <net/if_dl.h>
37
38#include "common/efx.h"
39
40#include "sfxge.h"
41
42static int
43sfxge_mac_stat_update(struct sfxge_softc *sc)
44{
45 struct sfxge_port *port = &sc->port;
46 efsys_mem_t *esmp = &(port->mac_stats.dma_buf);
47 clock_t now;
48 unsigned int count;
49 int rc;
50
51 mtx_lock(&port->lock);
51 SFXGE_PORT_LOCK(port);
52
53 if (port->init_state != SFXGE_PORT_STARTED) {
54 rc = 0;
55 goto out;
56 }
57
58 now = ticks;
59 if (now - port->mac_stats.update_time < hz) {

--- 17 unchanged lines hidden (view full) ---

77 port->mac_stats.decode_buf, NULL)) != EAGAIN)
78 goto out;
79
80 DELAY(100);
81 }
82
83 rc = ETIMEDOUT;
84out:
52
53 if (port->init_state != SFXGE_PORT_STARTED) {
54 rc = 0;
55 goto out;
56 }
57
58 now = ticks;
59 if (now - port->mac_stats.update_time < hz) {

--- 17 unchanged lines hidden (view full) ---

77 port->mac_stats.decode_buf, NULL)) != EAGAIN)
78 goto out;
79
80 DELAY(100);
81 }
82
83 rc = ETIMEDOUT;
84out:
85 mtx_unlock(&port->lock);
85 SFXGE_PORT_UNLOCK(port);
86 return (rc);
87}
88
89static int
90sfxge_mac_stat_handler(SYSCTL_HANDLER_ARGS)
91{
92 struct sfxge_softc *sc = arg1;
93 unsigned int id = arg2;

--- 71 unchanged lines hidden (view full) ---

165 struct sfxge_softc *sc;
166 struct sfxge_port *port;
167 unsigned int fcntl;
168 int error;
169
170 sc = arg1;
171 port = &sc->port;
172
86 return (rc);
87}
88
89static int
90sfxge_mac_stat_handler(SYSCTL_HANDLER_ARGS)
91{
92 struct sfxge_softc *sc = arg1;
93 unsigned int id = arg2;

--- 71 unchanged lines hidden (view full) ---

165 struct sfxge_softc *sc;
166 struct sfxge_port *port;
167 unsigned int fcntl;
168 int error;
169
170 sc = arg1;
171 port = &sc->port;
172
173 mtx_lock(&port->lock);
173 SFXGE_PORT_LOCK(port);
174
175 if (req->newptr != NULL) {
176 if ((error = SYSCTL_IN(req, &fcntl, sizeof(fcntl))) != 0)
177 goto out;
178
179 if (port->wanted_fc == fcntl)
180 goto out;
181

--- 4 unchanged lines hidden (view full) ---

186
187 error = efx_mac_fcntl_set(sc->enp, port->wanted_fc, B_TRUE);
188 } else {
189 error = SYSCTL_OUT(req, &port->wanted_fc,
190 sizeof(port->wanted_fc));
191 }
192
193out:
174
175 if (req->newptr != NULL) {
176 if ((error = SYSCTL_IN(req, &fcntl, sizeof(fcntl))) != 0)
177 goto out;
178
179 if (port->wanted_fc == fcntl)
180 goto out;
181

--- 4 unchanged lines hidden (view full) ---

186
187 error = efx_mac_fcntl_set(sc->enp, port->wanted_fc, B_TRUE);
188 } else {
189 error = SYSCTL_OUT(req, &port->wanted_fc,
190 sizeof(port->wanted_fc));
191 }
192
193out:
194 mtx_unlock(&port->lock);
194 SFXGE_PORT_UNLOCK(port);
195
196 return (error);
197}
198
199static int
200sfxge_port_link_fc_handler(SYSCTL_HANDLER_ARGS)
201{
202 struct sfxge_softc *sc;
203 struct sfxge_port *port;
204 unsigned int wanted_fc, link_fc;
205 int error;
206
207 sc = arg1;
208 port = &sc->port;
209
195
196 return (error);
197}
198
199static int
200sfxge_port_link_fc_handler(SYSCTL_HANDLER_ARGS)
201{
202 struct sfxge_softc *sc;
203 struct sfxge_port *port;
204 unsigned int wanted_fc, link_fc;
205 int error;
206
207 sc = arg1;
208 port = &sc->port;
209
210 mtx_lock(&port->lock);
210 SFXGE_PORT_LOCK(port);
211 if (port->init_state == SFXGE_PORT_STARTED && SFXGE_LINK_UP(sc))
212 efx_mac_fcntl_get(sc->enp, &wanted_fc, &link_fc);
213 else
214 link_fc = 0;
215 error = SYSCTL_OUT(req, &link_fc, sizeof(link_fc));
211 if (port->init_state == SFXGE_PORT_STARTED && SFXGE_LINK_UP(sc))
212 efx_mac_fcntl_get(sc->enp, &wanted_fc, &link_fc);
213 else
214 link_fc = 0;
215 error = SYSCTL_OUT(req, &link_fc, sizeof(link_fc));
216 mtx_unlock(&port->lock);
216 SFXGE_PORT_UNLOCK(port);
217
218 return (error);
219}
220
221#endif /* SFXGE_HAVE_PAUSE_MEDIAOPTS */
222
223static const uint64_t sfxge_link_baudrate[EFX_LINK_NMODES] = {
224 [EFX_LINK_10HDX] = IF_Mbps(10),

--- 32 unchanged lines hidden (view full) ---

257 efx_nic_t *enp;
258 struct sfxge_port *port;
259 efx_link_mode_t mode;
260
261 sc = (struct sfxge_softc *)arg;
262 enp = sc->enp;
263 port = &sc->port;
264
217
218 return (error);
219}
220
221#endif /* SFXGE_HAVE_PAUSE_MEDIAOPTS */
222
223static const uint64_t sfxge_link_baudrate[EFX_LINK_NMODES] = {
224 [EFX_LINK_10HDX] = IF_Mbps(10),

--- 32 unchanged lines hidden (view full) ---

257 efx_nic_t *enp;
258 struct sfxge_port *port;
259 efx_link_mode_t mode;
260
261 sc = (struct sfxge_softc *)arg;
262 enp = sc->enp;
263 port = &sc->port;
264
265 mtx_lock(&port->lock);
265 SFXGE_PORT_LOCK(port);
266
267 if (port->init_state != SFXGE_PORT_STARTED)
268 goto done;
269
270 /* This may sleep waiting for MCDI completion */
271 (void)efx_port_poll(enp, &mode);
272 sfxge_mac_link_update(sc, mode);
273
274done:
266
267 if (port->init_state != SFXGE_PORT_STARTED)
268 goto done;
269
270 /* This may sleep waiting for MCDI completion */
271 (void)efx_port_poll(enp, &mode);
272 sfxge_mac_link_update(sc, mode);
273
274done:
275 mtx_unlock(&port->lock);
275 SFXGE_PORT_UNLOCK(port);
276}
277
278static int
279sfxge_mac_filter_set_locked(struct sfxge_softc *sc)
280{
281 unsigned int bucket[EFX_MAC_HASH_BITS];
282 struct ifnet *ifp = sc->ifnet;
283 struct ifmultiaddr *ifma;

--- 31 unchanged lines hidden (view full) ---

315}
316
317int
318sfxge_mac_filter_set(struct sfxge_softc *sc)
319{
320 struct sfxge_port *port = &sc->port;
321 int rc;
322
276}
277
278static int
279sfxge_mac_filter_set_locked(struct sfxge_softc *sc)
280{
281 unsigned int bucket[EFX_MAC_HASH_BITS];
282 struct ifnet *ifp = sc->ifnet;
283 struct ifmultiaddr *ifma;

--- 31 unchanged lines hidden (view full) ---

315}
316
317int
318sfxge_mac_filter_set(struct sfxge_softc *sc)
319{
320 struct sfxge_port *port = &sc->port;
321 int rc;
322
323 mtx_lock(&port->lock);
323 SFXGE_PORT_LOCK(port);
324 /*
325 * The function may be called without softc_lock held in the
326 * case of SIOCADDMULTI and SIOCDELMULTI ioctls. ioctl handler
327 * checks IFF_DRV_RUNNING flag which implies port started, but
328 * it is not guaranteed to remain. softc_lock shared lock can't
329 * be held in the case of these ioctls processing, since it
330 * results in failure where kernel complains that non-sleepable
331 * lock is held in sleeping thread. Both problems are repeatable
332 * on LAG with LACP proto bring up.
333 */
334 if (port->init_state == SFXGE_PORT_STARTED)
335 rc = sfxge_mac_filter_set_locked(sc);
336 else
337 rc = 0;
324 /*
325 * The function may be called without softc_lock held in the
326 * case of SIOCADDMULTI and SIOCDELMULTI ioctls. ioctl handler
327 * checks IFF_DRV_RUNNING flag which implies port started, but
328 * it is not guaranteed to remain. softc_lock shared lock can't
329 * be held in the case of these ioctls processing, since it
330 * results in failure where kernel complains that non-sleepable
331 * lock is held in sleeping thread. Both problems are repeatable
332 * on LAG with LACP proto bring up.
333 */
334 if (port->init_state == SFXGE_PORT_STARTED)
335 rc = sfxge_mac_filter_set_locked(sc);
336 else
337 rc = 0;
338 mtx_unlock(&port->lock);
338 SFXGE_PORT_UNLOCK(port);
339 return (rc);
340}
341
342void
343sfxge_port_stop(struct sfxge_softc *sc)
344{
345 struct sfxge_port *port;
346 efx_nic_t *enp;
347
348 port = &sc->port;
349 enp = sc->enp;
350
339 return (rc);
340}
341
342void
343sfxge_port_stop(struct sfxge_softc *sc)
344{
345 struct sfxge_port *port;
346 efx_nic_t *enp;
347
348 port = &sc->port;
349 enp = sc->enp;
350
351 mtx_lock(&port->lock);
351 SFXGE_PORT_LOCK(port);
352
353 KASSERT(port->init_state == SFXGE_PORT_STARTED,
354 ("port not started"));
355
356 port->init_state = SFXGE_PORT_INITIALIZED;
357
358 port->mac_stats.update_time = 0;
359
360 /* This may call MCDI */
361 (void)efx_mac_drain(enp, B_TRUE);
362
363 (void)efx_mac_stats_periodic(enp, &port->mac_stats.dma_buf, 0, B_FALSE);
364
365 port->link_mode = EFX_LINK_UNKNOWN;
366
367 /* Destroy the common code port object. */
368 efx_port_fini(sc->enp);
369
352
353 KASSERT(port->init_state == SFXGE_PORT_STARTED,
354 ("port not started"));
355
356 port->init_state = SFXGE_PORT_INITIALIZED;
357
358 port->mac_stats.update_time = 0;
359
360 /* This may call MCDI */
361 (void)efx_mac_drain(enp, B_TRUE);
362
363 (void)efx_mac_stats_periodic(enp, &port->mac_stats.dma_buf, 0, B_FALSE);
364
365 port->link_mode = EFX_LINK_UNKNOWN;
366
367 /* Destroy the common code port object. */
368 efx_port_fini(sc->enp);
369
370 mtx_unlock(&port->lock);
370 SFXGE_PORT_UNLOCK(port);
371}
372
373int
374sfxge_port_start(struct sfxge_softc *sc)
375{
376 uint8_t mac_addr[ETHER_ADDR_LEN];
377 struct ifnet *ifp = sc->ifnet;
378 struct sfxge_port *port;
379 efx_nic_t *enp;
380 size_t pdu;
381 int rc;
382
383 port = &sc->port;
384 enp = sc->enp;
385
371}
372
373int
374sfxge_port_start(struct sfxge_softc *sc)
375{
376 uint8_t mac_addr[ETHER_ADDR_LEN];
377 struct ifnet *ifp = sc->ifnet;
378 struct sfxge_port *port;
379 efx_nic_t *enp;
380 size_t pdu;
381 int rc;
382
383 port = &sc->port;
384 enp = sc->enp;
385
386 mtx_lock(&port->lock);
386 SFXGE_PORT_LOCK(port);
387
388 KASSERT(port->init_state == SFXGE_PORT_INITIALIZED,
389 ("port not initialized"));
390
391 /* Initialize the port object in the common code. */
392 if ((rc = efx_port_init(sc->enp)) != 0)
393 goto fail;
394

--- 26 unchanged lines hidden (view full) ---

421
422 if ((rc = efx_phy_adv_cap_set(sc->enp, sc->media.ifm_cur->ifm_data))
423 != 0)
424 goto fail4;
425
426 port->init_state = SFXGE_PORT_STARTED;
427
428 /* Single poll in case there were missing initial events */
387
388 KASSERT(port->init_state == SFXGE_PORT_INITIALIZED,
389 ("port not initialized"));
390
391 /* Initialize the port object in the common code. */
392 if ((rc = efx_port_init(sc->enp)) != 0)
393 goto fail;
394

--- 26 unchanged lines hidden (view full) ---

421
422 if ((rc = efx_phy_adv_cap_set(sc->enp, sc->media.ifm_cur->ifm_data))
423 != 0)
424 goto fail4;
425
426 port->init_state = SFXGE_PORT_STARTED;
427
428 /* Single poll in case there were missing initial events */
429 mtx_unlock(&port->lock);
429 SFXGE_PORT_UNLOCK(port);
430 sfxge_mac_poll_work(sc, 0);
431
432 return (0);
433
434fail4:
435 (void)efx_mac_drain(enp, B_TRUE);
436fail3:
437 (void)efx_mac_stats_periodic(enp, &port->mac_stats.dma_buf,
438 0, B_FALSE);
439fail2:
440 efx_port_fini(sc->enp);
441fail:
430 sfxge_mac_poll_work(sc, 0);
431
432 return (0);
433
434fail4:
435 (void)efx_mac_drain(enp, B_TRUE);
436fail3:
437 (void)efx_mac_stats_periodic(enp, &port->mac_stats.dma_buf,
438 0, B_FALSE);
439fail2:
440 efx_port_fini(sc->enp);
441fail:
442 mtx_unlock(&port->lock);
442 SFXGE_PORT_UNLOCK(port);
443
444 return (rc);
445}
446
447static int
448sfxge_phy_stat_update(struct sfxge_softc *sc)
449{
450 struct sfxge_port *port = &sc->port;
451 efsys_mem_t *esmp = &port->phy_stats.dma_buf;
452 clock_t now;
453 unsigned int count;
454 int rc;
455
443
444 return (rc);
445}
446
447static int
448sfxge_phy_stat_update(struct sfxge_softc *sc)
449{
450 struct sfxge_port *port = &sc->port;
451 efsys_mem_t *esmp = &port->phy_stats.dma_buf;
452 clock_t now;
453 unsigned int count;
454 int rc;
455
456 mtx_lock(&port->lock);
456 SFXGE_PORT_LOCK(port);
457
458 if (port->init_state != SFXGE_PORT_STARTED) {
459 rc = 0;
460 goto out;
461 }
462
463 now = ticks;
464 if (now - port->phy_stats.update_time < hz) {

--- 17 unchanged lines hidden (view full) ---

482 port->phy_stats.decode_buf)) != EAGAIN)
483 goto out;
484
485 DELAY(100);
486 }
487
488 rc = ETIMEDOUT;
489out:
457
458 if (port->init_state != SFXGE_PORT_STARTED) {
459 rc = 0;
460 goto out;
461 }
462
463 now = ticks;
464 if (now - port->phy_stats.update_time < hz) {

--- 17 unchanged lines hidden (view full) ---

482 port->phy_stats.decode_buf)) != EAGAIN)
483 goto out;
484
485 DELAY(100);
486 }
487
488 rc = ETIMEDOUT;
489out:
490 mtx_unlock(&port->lock);
490 SFXGE_PORT_UNLOCK(port);
491 return (rc);
492}
493
494static int
495sfxge_phy_stat_handler(SYSCTL_HANDLER_ARGS)
496{
497 struct sfxge_softc *sc = arg1;
498 unsigned int id = arg2;

--- 50 unchanged lines hidden (view full) ---

549
550 /* Finish with PHY DMA memory */
551 sfxge_dma_free(&port->phy_stats.dma_buf);
552 free(port->phy_stats.decode_buf, M_SFXGE);
553
554 sfxge_dma_free(esmp);
555 free(port->mac_stats.decode_buf, M_SFXGE);
556
491 return (rc);
492}
493
494static int
495sfxge_phy_stat_handler(SYSCTL_HANDLER_ARGS)
496{
497 struct sfxge_softc *sc = arg1;
498 unsigned int id = arg2;

--- 50 unchanged lines hidden (view full) ---

549
550 /* Finish with PHY DMA memory */
551 sfxge_dma_free(&port->phy_stats.dma_buf);
552 free(port->phy_stats.decode_buf, M_SFXGE);
553
554 sfxge_dma_free(esmp);
555 free(port->mac_stats.decode_buf, M_SFXGE);
556
557 mtx_destroy(&port->lock);
557 SFXGE_PORT_LOCK_DESTROY(port);
558
559 port->sc = NULL;
560}
561
562int
563sfxge_port_init(struct sfxge_softc *sc)
564{
565 struct sfxge_port *port;

--- 6 unchanged lines hidden (view full) ---

572 mac_stats_buf = &port->mac_stats.dma_buf;
573 phy_stats_buf = &port->phy_stats.dma_buf;
574
575 KASSERT(port->init_state == SFXGE_PORT_UNINITIALIZED,
576 ("Port already initialized"));
577
578 port->sc = sc;
579
558
559 port->sc = NULL;
560}
561
562int
563sfxge_port_init(struct sfxge_softc *sc)
564{
565 struct sfxge_port *port;

--- 6 unchanged lines hidden (view full) ---

572 mac_stats_buf = &port->mac_stats.dma_buf;
573 phy_stats_buf = &port->phy_stats.dma_buf;
574
575 KASSERT(port->init_state == SFXGE_PORT_UNINITIALIZED,
576 ("Port already initialized"));
577
578 port->sc = sc;
579
580 mtx_init(&port->lock, "sfxge_port", NULL, MTX_DEF);
580 SFXGE_PORT_LOCK_INIT(port, "sfxge_port");
581
582 port->phy_stats.decode_buf = malloc(EFX_PHY_NSTATS * sizeof(uint32_t),
583 M_SFXGE, M_WAITOK | M_ZERO);
584 if ((rc = sfxge_dma_alloc(sc, EFX_PHY_STATS_SIZE, phy_stats_buf)) != 0)
585 goto fail;
586 sfxge_phy_stat_init(sc);
587
588 sysctl_ctx = device_get_sysctl_ctx(sc->dev);

--- 21 unchanged lines hidden (view full) ---

610
611 return (0);
612
613fail2:
614 free(port->mac_stats.decode_buf, M_SFXGE);
615 sfxge_dma_free(phy_stats_buf);
616fail:
617 free(port->phy_stats.decode_buf, M_SFXGE);
581
582 port->phy_stats.decode_buf = malloc(EFX_PHY_NSTATS * sizeof(uint32_t),
583 M_SFXGE, M_WAITOK | M_ZERO);
584 if ((rc = sfxge_dma_alloc(sc, EFX_PHY_STATS_SIZE, phy_stats_buf)) != 0)
585 goto fail;
586 sfxge_phy_stat_init(sc);
587
588 sysctl_ctx = device_get_sysctl_ctx(sc->dev);

--- 21 unchanged lines hidden (view full) ---

610
611 return (0);
612
613fail2:
614 free(port->mac_stats.decode_buf, M_SFXGE);
615 sfxge_dma_free(phy_stats_buf);
616fail:
617 free(port->phy_stats.decode_buf, M_SFXGE);
618 (void)mtx_destroy(&port->lock);
618 SFXGE_PORT_LOCK_DESTROY(port);
619 port->sc = NULL;
620 return (rc);
621}
622
623static int sfxge_link_mode[EFX_PHY_MEDIA_NTYPES][EFX_LINK_NMODES] = {
624 [EFX_PHY_MEDIA_CX4] = {
625 [EFX_LINK_10000FDX] = IFM_ETHER | IFM_FDX | IFM_10G_CX4,
626 },

--- 23 unchanged lines hidden (view full) ---

650static void
651sfxge_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
652{
653 struct sfxge_softc *sc;
654 efx_phy_media_type_t medium_type;
655 efx_link_mode_t mode;
656
657 sc = ifp->if_softc;
619 port->sc = NULL;
620 return (rc);
621}
622
623static int sfxge_link_mode[EFX_PHY_MEDIA_NTYPES][EFX_LINK_NMODES] = {
624 [EFX_PHY_MEDIA_CX4] = {
625 [EFX_LINK_10000FDX] = IFM_ETHER | IFM_FDX | IFM_10G_CX4,
626 },

--- 23 unchanged lines hidden (view full) ---

650static void
651sfxge_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
652{
653 struct sfxge_softc *sc;
654 efx_phy_media_type_t medium_type;
655 efx_link_mode_t mode;
656
657 sc = ifp->if_softc;
658 sx_xlock(&sc->softc_lock);
658 SFXGE_ADAPTER_LOCK(sc);
659
660 ifmr->ifm_status = IFM_AVALID;
661 ifmr->ifm_active = IFM_ETHER;
662
663 if (SFXGE_RUNNING(sc) && SFXGE_LINK_UP(sc)) {
664 ifmr->ifm_status |= IFM_ACTIVE;
665
666 efx_phy_media_type_get(sc->enp, &medium_type);
667 mode = sc->port.link_mode;
668 ifmr->ifm_active |= sfxge_link_mode[medium_type][mode];
669 ifmr->ifm_active |= sfxge_port_link_fc_ifm(sc);
670 }
671
659
660 ifmr->ifm_status = IFM_AVALID;
661 ifmr->ifm_active = IFM_ETHER;
662
663 if (SFXGE_RUNNING(sc) && SFXGE_LINK_UP(sc)) {
664 ifmr->ifm_status |= IFM_ACTIVE;
665
666 efx_phy_media_type_get(sc->enp, &medium_type);
667 mode = sc->port.link_mode;
668 ifmr->ifm_active |= sfxge_link_mode[medium_type][mode];
669 ifmr->ifm_active |= sfxge_port_link_fc_ifm(sc);
670 }
671
672 sx_xunlock(&sc->softc_lock);
672 SFXGE_ADAPTER_UNLOCK(sc);
673}
674
675static int
676sfxge_media_change(struct ifnet *ifp)
677{
678 struct sfxge_softc *sc;
679 struct ifmedia_entry *ifm;
680 int rc;
681
682 sc = ifp->if_softc;
683 ifm = sc->media.ifm_cur;
684
673}
674
675static int
676sfxge_media_change(struct ifnet *ifp)
677{
678 struct sfxge_softc *sc;
679 struct ifmedia_entry *ifm;
680 int rc;
681
682 sc = ifp->if_softc;
683 ifm = sc->media.ifm_cur;
684
685 sx_xlock(&sc->softc_lock);
685 SFXGE_ADAPTER_LOCK(sc);
686
687 if (!SFXGE_RUNNING(sc)) {
688 rc = 0;
689 goto out;
690 }
691
692 rc = efx_mac_fcntl_set(sc->enp, sfxge_port_wanted_fc(sc), B_TRUE);
693 if (rc != 0)
694 goto out;
695
696 rc = efx_phy_adv_cap_set(sc->enp, ifm->ifm_data);
697out:
686
687 if (!SFXGE_RUNNING(sc)) {
688 rc = 0;
689 goto out;
690 }
691
692 rc = efx_mac_fcntl_set(sc->enp, sfxge_port_wanted_fc(sc), B_TRUE);
693 if (rc != 0)
694 goto out;
695
696 rc = efx_phy_adv_cap_set(sc->enp, ifm->ifm_data);
697out:
698 sx_xunlock(&sc->softc_lock);
698 SFXGE_ADAPTER_UNLOCK(sc);
699
700 return (rc);
701}
702
703int sfxge_port_ifmedia_init(struct sfxge_softc *sc)
704{
705 efx_phy_media_type_t medium_type;
706 uint32_t cap_mask, mode_cap_mask;

--- 92 unchanged lines hidden ---
699
700 return (rc);
701}
702
703int sfxge_port_ifmedia_init(struct sfxge_softc *sc)
704{
705 efx_phy_media_type_t medium_type;
706 uint32_t cap_mask, mode_cap_mask;

--- 92 unchanged lines hidden ---