ixgbe: Replace the TX lockmgr lock by a serializer
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 9 Sep 2012 08:37:34 +0000 (10:37 +0200)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Mon, 10 Sep 2012 16:18:52 +0000 (18:18 +0200)
sys/dev/netif/ixgbe/ixgbe.c
sys/dev/netif/ixgbe/ixgbe.h

index 6700dca..d5eeac0 100644 (file)
@@ -2642,9 +2642,7 @@ ixgbe_allocate_queues(struct adapter *adapter)
                txr->me = i;
 
                /* Initialize the TX side lock */
-               ksnprintf(txr->lock_name, sizeof(txr->lock_name), "%s:tx(%d)",
-                   device_get_nameunit(dev), txr->me);
-               lockinit(&txr->tx_lock, txr->lock_name, 0, LK_CANRECURSE);
+               IXGBE_TX_LOCK_INIT(txr);
 
                if (ixgbe_dma_malloc(adapter, tsize,
                        &txr->txdma, BUS_DMA_NOWAIT)) {
@@ -3370,7 +3368,7 @@ ixgbe_txeof(struct tx_ring *txr)
        struct ixgbe_tx_buf *tx_buffer;
        struct ixgbe_legacy_tx_desc *tx_desc, *eop_desc;
 
-       KKASSERT(lockstatus(&txr->tx_lock, curthread) != 0);
+       IXGBE_TX_LOCK_ASSERT(txr);
 
 #ifdef DEV_NETMAP
        if (ifp->if_capenable & IFCAP_NETMAP) {
index 49cee00..fe9f7e8 100644 (file)
@@ -277,7 +277,7 @@ struct ix_queue {
  */
 struct tx_ring {
         struct adapter         *adapter;
-       struct lock             tx_lock;
+       struct lwkt_serialize   tx_serialize;
        u32                     me;
        int                     queue_status;
        int                     watchdog_time;
@@ -466,18 +466,19 @@ struct adapter {
 
 #define IXGBE_CORE_LOCK_INIT(_sc, _name) \
         lockinit(&(_sc)->core_lock, _name, 0, LK_CANRECURSE)
+#define IXGBE_TX_LOCK_INIT(_sc)                  lwkt_serialize_init(&(_sc)->tx_serialize)
 #define IXGBE_CORE_LOCK_DESTROY(_sc)      lockuninit(&(_sc)->core_lock)
-#define IXGBE_TX_LOCK_DESTROY(_sc)        lockuninit(&(_sc)->tx_lock)
+#define IXGBE_TX_LOCK_DESTROY(_sc)
 #define IXGBE_RX_LOCK_DESTROY(_sc)        lockuninit(&(_sc)->rx_lock)
 #define IXGBE_CORE_LOCK(_sc)              lockmgr(&(_sc)->core_lock, LK_EXCLUSIVE)
-#define IXGBE_TX_LOCK(_sc)                lockmgr(&(_sc)->tx_lock, LK_EXCLUSIVE)
-#define IXGBE_TX_TRYLOCK(_sc)             lockmgr(&(_sc)->tx_mtx, LK_EXCLUSIVE|LK_NOWAIT)
+#define IXGBE_TX_LOCK(_sc)                lwkt_serialize_enter(&(_sc)->tx_serialize)
+#define IXGBE_TX_TRYLOCK(_sc)             lwkt_serialize_try(&(_sc)->tx_serialize)
 #define IXGBE_RX_LOCK(_sc)                lockmgr(&(_sc)->rx_lock, LK_EXCLUSIVE)
 #define IXGBE_CORE_UNLOCK(_sc)            lockmgr(&(_sc)->core_lock, LK_RELEASE)
-#define IXGBE_TX_UNLOCK(_sc)              lockmgr(&(_sc)->tx_lock, LK_RELEASE)
+#define IXGBE_TX_UNLOCK(_sc)              lwkt_serialize_exit(&(_sc)->tx_serialize)
 #define IXGBE_RX_UNLOCK(_sc)              lockmgr(&(_sc)->rx_lock, LK_RELEASE)
 #define IXGBE_CORE_LOCK_ASSERT(_sc)       KKASSERT(lockstatus(&(_sc)->core_lock, curthread) !=0)
-#define IXGBE_TX_LOCK_ASSERT(_sc)         KKASSERT(lockstatus(&(_sc)->tx_lock, curthread) != 0)
+#define IXGBE_TX_LOCK_ASSERT(_sc)         ASSERT_SERIALIZED(&(_sc)->tx_serialize)
 
 
 static inline bool