Deleted Added
full compact
sfxge_tx.c (282942) sfxge_tx.c (282997)
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

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

38 *
39 * So, event queue plus label mapping to Tx queue index is:
40 * if event queue index is 0, TxQ-index = TxQ-label * [0..SFXGE_TXQ_NTYPES)
41 * else TxQ-index = SFXGE_TXQ_NTYPES + EvQ-index - 1
42 * See sfxge_get_txq_by_label() sfxge_ev.c
43 */
44
45#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

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

38 *
39 * So, event queue plus label mapping to Tx queue index is:
40 * if event queue index is 0, TxQ-index = TxQ-label * [0..SFXGE_TXQ_NTYPES)
41 * else TxQ-index = SFXGE_TXQ_NTYPES + EvQ-index - 1
42 * See sfxge_get_txq_by_label() sfxge_ev.c
43 */
44
45#include <sys/cdefs.h>
46__FBSDID("$FreeBSD: head/sys/dev/sfxge/sfxge_tx.c 282942 2015-05-15 06:50:59Z arybchik $");
46__FBSDID("$FreeBSD: head/sys/dev/sfxge/sfxge_tx.c 282997 2015-05-16 05:37:47Z arybchik $");
47
48#include <sys/types.h>
49#include <sys/mbuf.h>
50#include <sys/smp.h>
51#include <sys/socket.h>
52#include <sys/sysctl.h>
53#include <sys/syslog.h>
54

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

597
598/*
599 * Called from if_transmit - will try to grab the txq lock and enqueue to the
600 * put list if it succeeds, otherwise try to push onto the defer list if space.
601 */
602int
603sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m)
604{
47
48#include <sys/types.h>
49#include <sys/mbuf.h>
50#include <sys/smp.h>
51#include <sys/socket.h>
52#include <sys/sysctl.h>
53#include <sys/syslog.h>
54

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

597
598/*
599 * Called from if_transmit - will try to grab the txq lock and enqueue to the
600 * put list if it succeeds, otherwise try to push onto the defer list if space.
601 */
602int
603sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m)
604{
605 int locked;
606 int rc;
607
608 if (!SFXGE_LINK_UP(txq->sc)) {
609 rc = ENETDOWN;
610 atomic_add_long(&txq->netdown_drops, 1);
611 goto fail;
612 }
613
614 /*
615 * Try to grab the txq lock. If we are able to get the lock,
616 * the packet will be appended to the "get list" of the deferred
617 * packet list. Otherwise, it will be pushed on the "put list".
618 */
605 int rc;
606
607 if (!SFXGE_LINK_UP(txq->sc)) {
608 rc = ENETDOWN;
609 atomic_add_long(&txq->netdown_drops, 1);
610 goto fail;
611 }
612
613 /*
614 * Try to grab the txq lock. If we are able to get the lock,
615 * the packet will be appended to the "get list" of the deferred
616 * packet list. Otherwise, it will be pushed on the "put list".
617 */
619 locked = SFXGE_TXQ_TRYLOCK(txq);
620
621 if (locked) {
618 if (SFXGE_TXQ_TRYLOCK(txq)) {
622 /* First swizzle put-list to get-list to keep order */
623 sfxge_tx_qdpl_swizzle(txq);
624
625 rc = sfxge_tx_qdpl_put_locked(txq, m);
626 if (rc != 0) {
627 SFXGE_TXQ_UNLOCK(txq);
628 goto fail;
629 }
619 /* First swizzle put-list to get-list to keep order */
620 sfxge_tx_qdpl_swizzle(txq);
621
622 rc = sfxge_tx_qdpl_put_locked(txq, m);
623 if (rc != 0) {
624 SFXGE_TXQ_UNLOCK(txq);
625 goto fail;
626 }
627
628 /* Try to service the list. */
629 sfxge_tx_qdpl_service(txq);
630 /* Lock has been dropped. */
630 } else {
631 rc = sfxge_tx_qdpl_put_unlocked(txq, m);
632 if (rc != 0)
633 goto fail;
634
635 /*
636 * Try to grab the lock again.
637 *
638 * If we are able to get the lock, we need to process
639 * the deferred packet list. If we are not able to get
640 * the lock, another thread is processing the list.
641 */
631 } else {
632 rc = sfxge_tx_qdpl_put_unlocked(txq, m);
633 if (rc != 0)
634 goto fail;
635
636 /*
637 * Try to grab the lock again.
638 *
639 * If we are able to get the lock, we need to process
640 * the deferred packet list. If we are not able to get
641 * the lock, another thread is processing the list.
642 */
642 locked = SFXGE_TXQ_TRYLOCK(txq);
643 if (SFXGE_TXQ_TRYLOCK(txq)) {
644 sfxge_tx_qdpl_service(txq);
645 /* Lock has been dropped. */
646 }
643 }
644
647 }
648
645 if (locked) {
646 /* Try to service the list. */
647 sfxge_tx_qdpl_service(txq);
648 /* Lock has been dropped. */
649 }
649 SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
650
651 return (0);
652
653fail:
654 m_freem(m);
655 return (rc);
656}
657

--- 975 unchanged lines hidden ---
650
651 return (0);
652
653fail:
654 m_freem(m);
655 return (rc);
656}
657

--- 975 unchanged lines hidden ---