Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


1731                 /* LINTED: E_CASE_FALLTHRU */
1732         case M_MULTIDATA:
1733                 /* Only call gld_start() directly if nothing queued ahead */
1734                 /* No guarantees about ordering with different threads */
1735                 if (q->q_first)
1736                         goto use_wsrv;
1737 
1738                 /*
1739                  * This can happen if wsrv has taken off the last mblk but
1740                  * is still processing it.
1741                  */
1742                 membar_consumer();
1743                 if (gld->gld_in_wsrv)
1744                         goto use_wsrv;
1745 
1746                 /*
1747                  * Keep a count of current wput calls to start.
1748                  * Nonzero count delays any attempted DL_UNBIND.
1749                  * See comments above gld_start().
1750                  */
1751                 atomic_add_32((uint32_t *)&gld->gld_wput_count, 1);
1752                 membar_enter();
1753 
1754                 /* Recheck state now wput_count is set to prevent DL_UNBIND */
1755                 /* If this Q is in process of DL_UNBIND, don't call start */
1756                 if (gld->gld_state != DL_IDLE || gld->gld_in_unbind) {
1757                         /* Extremely unlikely */
1758                         atomic_add_32((uint32_t *)&gld->gld_wput_count, -1);
1759                         goto use_wsrv;
1760                 }
1761 
1762                 /*
1763                  * Get the priority value. Note that in raw mode, the
1764                  * per-packet priority value kept in b_band is ignored.
1765                  */
1766                 upri = (gld->gld_flags & GLD_RAW) ? gld->gld_upri :
1767                     UPRI(gld, mp->b_band);
1768 
1769                 rc = (multidata) ? gld_start_mdt(q, mp, GLD_WPUT) :
1770                     gld_start(q, mp, GLD_WPUT, upri);
1771 
1772                 /* Allow DL_UNBIND again */
1773                 membar_exit();
1774                 atomic_add_32((uint32_t *)&gld->gld_wput_count, -1);
1775 
1776                 if (rc == GLD_NORESOURCES)
1777                         qenable(q);
1778                 break;  /*  Done with this packet */
1779 
1780 use_wsrv:
1781                 /* Q not empty, in DL_DETACH, or start gave NORESOURCES */
1782                 (void) putq(q, mp);
1783                 qenable(q);
1784                 break;
1785 
1786         case M_IOCTL:
1787                 /* ioctl relies on wsrv single threading per queue */
1788                 (void) putq(q, mp);
1789                 qenable(q);
1790                 break;
1791 
1792         case M_CTL:
1793                 (void) putq(q, mp);
1794                 qenable(q);




1731                 /* LINTED: E_CASE_FALLTHRU */
1732         case M_MULTIDATA:
1733                 /* Only call gld_start() directly if nothing queued ahead */
1734                 /* No guarantees about ordering with different threads */
1735                 if (q->q_first)
1736                         goto use_wsrv;
1737 
1738                 /*
1739                  * This can happen if wsrv has taken off the last mblk but
1740                  * is still processing it.
1741                  */
1742                 membar_consumer();
1743                 if (gld->gld_in_wsrv)
1744                         goto use_wsrv;
1745 
1746                 /*
1747                  * Keep a count of current wput calls to start.
1748                  * Nonzero count delays any attempted DL_UNBIND.
1749                  * See comments above gld_start().
1750                  */
1751                 atomic_inc_32((uint32_t *)&gld->gld_wput_count);
1752                 membar_enter();
1753 
1754                 /* Recheck state now wput_count is set to prevent DL_UNBIND */
1755                 /* If this Q is in process of DL_UNBIND, don't call start */
1756                 if (gld->gld_state != DL_IDLE || gld->gld_in_unbind) {
1757                         /* Extremely unlikely */
1758                         atomic_dec_32((uint32_t *)&gld->gld_wput_count);
1759                         goto use_wsrv;
1760                 }
1761 
1762                 /*
1763                  * Get the priority value. Note that in raw mode, the
1764                  * per-packet priority value kept in b_band is ignored.
1765                  */
1766                 upri = (gld->gld_flags & GLD_RAW) ? gld->gld_upri :
1767                     UPRI(gld, mp->b_band);
1768 
1769                 rc = (multidata) ? gld_start_mdt(q, mp, GLD_WPUT) :
1770                     gld_start(q, mp, GLD_WPUT, upri);
1771 
1772                 /* Allow DL_UNBIND again */
1773                 membar_exit();
1774                 atomic_dec_32((uint32_t *)&gld->gld_wput_count);
1775 
1776                 if (rc == GLD_NORESOURCES)
1777                         qenable(q);
1778                 break;  /*  Done with this packet */
1779 
1780 use_wsrv:
1781                 /* Q not empty, in DL_DETACH, or start gave NORESOURCES */
1782                 (void) putq(q, mp);
1783                 qenable(q);
1784                 break;
1785 
1786         case M_IOCTL:
1787                 /* ioctl relies on wsrv single threading per queue */
1788                 (void) putq(q, mp);
1789                 qenable(q);
1790                 break;
1791 
1792         case M_CTL:
1793                 (void) putq(q, mp);
1794                 qenable(q);