Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/ipp/dlcosmk/dlcosmk.c
+++ new/usr/src/uts/common/ipp/dlcosmk/dlcosmk.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #include <sys/types.h>
27 27 #include <sys/stream.h>
28 28 #include <sys/dlpi.h>
29 29 #include <sys/strsun.h>
30 30 #include <netinet/in.h>
31 31 #include <netinet/ip6.h>
32 32 #include <inet/common.h>
33 33 #include <inet/ip.h>
34 34 #include <inet/ip6.h>
35 35 #include <inet/ip_if.h>
36 36 #include <ipp/dlcosmk/dlcosmk_impl.h>
37 37
38 38 /* Module to mark the 802.1d user priority field for a given packet */
39 39
40 40 /* Debug level */
41 41 int dlcosmk_debug = 0;
42 42
43 43 /*
44 44 * Given a packet, this module marks the mblk with the appropriate b_band or
45 45 * dl_max value so that the VLAN driver marks the outgoing frame with the
46 46 * configured 802.1D user_priority value. For non-VLAN devices or for inbound
47 47 * packets, this module does not do anything (i.e. the packet is processed by
48 48 * the next action in the list, if present).
49 49 * This module does not free any mblks or packets in case or errors.
50 50 */
51 51
52 52 int
53 53 dlcosmk_process(mblk_t **mpp, dlcosmk_data_t *dlcosmk_data, uint32_t ill_index,
54 54 ip_proc_t proc)
55 55 {
56 56 ill_t *ill = NULL;
57 57 mblk_t *mp;
58 58
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
59 59 ASSERT((mpp != NULL) && (*mpp != NULL));
60 60 mp = *mpp;
61 61
62 62 /*
63 63 * The action module will receive an M_DATA or an M_CTL followed
64 64 * by an M_DATA. In the latter case skip the M_CTL.
65 65 */
66 66 if (mp->b_datap->db_type != M_DATA) {
67 67 if ((mp->b_cont == NULL) ||
68 68 (mp->b_cont->b_datap->db_type != M_DATA)) {
69 - atomic_add_64(&dlcosmk_data->epackets, 1);
69 + atomic_inc_64(&dlcosmk_data->epackets);
70 70 dlcosmk0dbg(("dlcosmk_process: no data\n"));
71 71 return (EINVAL);
72 72 }
73 73 }
74 74
75 75 /* Update global stats */
76 - atomic_add_64(&dlcosmk_data->npackets, 1);
76 + atomic_inc_64(&dlcosmk_data->npackets);
77 77
78 78 /*
79 79 * This should only be called for outgoing packets. For inbound, just
80 80 * send it along.
81 81 */
82 82 if ((proc == IPP_LOCAL_IN) || (proc == IPP_FWD_IN)) {
83 83 dlcosmk2dbg(("dlcosmk_process:cannot mark incoming packets\n"));
84 - atomic_add_64(&dlcosmk_data->ipackets, 1);
84 + atomic_inc_64(&dlcosmk_data->ipackets);
85 85 return (0);
86 86 }
87 87
88 88 if ((ill_index == 0) ||
89 89 ((ill = ill_lookup_on_ifindex_global_instance(ill_index,
90 90 B_FALSE)) == NULL)) {
91 91 dlcosmk2dbg(("dlcosmk_process:invalid ill index %u\n",
92 92 ill_index));
93 - atomic_add_64(&dlcosmk_data->ipackets, 1);
93 + atomic_inc_64(&dlcosmk_data->ipackets);
94 94 return (0);
95 95 }
96 96
97 97 /*
98 98 * Check if the interface supports CoS marking. If not send it to the
99 99 * next action in the chain
100 100 */
101 101 if (!(ill->ill_flags & ILLF_COS_ENABLED)) {
102 102 dlcosmk2dbg(("dlcosmk_process:ill %u does not support CoS\n",
103 103 ill_index));
104 - atomic_add_64(&dlcosmk_data->ipackets, 1);
104 + atomic_inc_64(&dlcosmk_data->ipackets);
105 105 ill_refrele(ill);
106 106 return (0);
107 107 }
108 108 ill_refrele(ill);
109 109
110 110
111 111 /*
112 112 * Mark the b_band for fastpath messages or dl_priority.dl_max for
113 113 * DL_UNITDATA_REQ messages. For, others just pass it along.
114 114 */
115 115 switch (DB_TYPE(mp)) {
116 116 case M_PROTO:
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
117 117 case M_PCPROTO:
118 118 { /* DL_UNITDATA */
119 119 dl_unitdata_req_t *dlur;
120 120 dlur = (dl_unitdata_req_t *)mp->b_rptr;
121 121
122 122 /* DL_UNITDATA message?? */
123 123 if (dlur->dl_primitive == DL_UNITDATA_REQ) {
124 124 dlur->dl_priority.dl_max =
125 125 dlcosmk_data->dl_max;
126 126 } else {
127 - atomic_add_64(&dlcosmk_data->ipackets,
128 - 1);
127 + atomic_inc_64(&dlcosmk_data->ipackets);
129 128 }
130 129 break;
131 130 }
132 131 case M_DATA:
133 132 /* fastpath message */
134 133 mp->b_band = dlcosmk_data->b_band;
135 134 break;
136 135 default:
137 - atomic_add_64(&dlcosmk_data->ipackets, 1);
136 + atomic_inc_64(&dlcosmk_data->ipackets);
138 137 break;
139 138 }
140 139
141 140 return (0);
142 141 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX