4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/types.h>
27 #include <sys/stream.h>
29 #include <sys/strsun.h>
30 #include <netinet/in.h>
31 #include <netinet/ip6.h>
32 #include <inet/common.h>
35 #include <inet/ip_if.h>
36 #include <ipp/dlcosmk/dlcosmk_impl.h>
38 /* Module to mark the 802.1d user priority field for a given packet */
41 int dlcosmk_debug
= 0;
44 * Given a packet, this module marks the mblk with the appropriate b_band or
45 * dl_max value so that the VLAN driver marks the outgoing frame with the
46 * configured 802.1D user_priority value. For non-VLAN devices or for inbound
47 * packets, this module does not do anything (i.e. the packet is processed by
48 * the next action in the list, if present).
49 * This module does not free any mblks or packets in case or errors.
53 dlcosmk_process(mblk_t
**mpp
, dlcosmk_data_t
*dlcosmk_data
, uint32_t ill_index
,
59 ASSERT((mpp
!= NULL
) && (*mpp
!= NULL
));
63 * The action module will receive an M_DATA or an M_CTL followed
64 * by an M_DATA. In the latter case skip the M_CTL.
66 if (mp
->b_datap
->db_type
!= M_DATA
) {
67 if ((mp
->b_cont
== NULL
) ||
68 (mp
->b_cont
->b_datap
->db_type
!= M_DATA
)) {
69 atomic_inc_64(&dlcosmk_data
->epackets
);
70 dlcosmk0dbg(("dlcosmk_process: no data\n"));
75 /* Update global stats */
76 atomic_inc_64(&dlcosmk_data
->npackets
);
79 * This should only be called for outgoing packets. For inbound, just
82 if ((proc
== IPP_LOCAL_IN
) || (proc
== IPP_FWD_IN
)) {
83 dlcosmk2dbg(("dlcosmk_process:cannot mark incoming packets\n"));
84 atomic_inc_64(&dlcosmk_data
->ipackets
);
88 if ((ill_index
== 0) ||
89 ((ill
= ill_lookup_on_ifindex_global_instance(ill_index
,
91 dlcosmk2dbg(("dlcosmk_process:invalid ill index %u\n",
93 atomic_inc_64(&dlcosmk_data
->ipackets
);
98 * Check if the interface supports CoS marking. If not send it to the
99 * next action in the chain
101 if (!(ill
->ill_flags
& ILLF_COS_ENABLED
)) {
102 dlcosmk2dbg(("dlcosmk_process:ill %u does not support CoS\n",
104 atomic_inc_64(&dlcosmk_data
->ipackets
);
112 * Mark the b_band for fastpath messages or dl_priority.dl_max for
113 * DL_UNITDATA_REQ messages. For, others just pass it along.
115 switch (DB_TYPE(mp
)) {
119 dl_unitdata_req_t
*dlur
;
120 dlur
= (dl_unitdata_req_t
*)mp
->b_rptr
;
122 /* DL_UNITDATA message?? */
123 if (dlur
->dl_primitive
== DL_UNITDATA_REQ
) {
124 dlur
->dl_priority
.dl_max
=
125 dlcosmk_data
->dl_max
;
127 atomic_inc_64(&dlcosmk_data
->ipackets
);
132 /* fastpath message */
133 mp
->b_band
= dlcosmk_data
->b_band
;
136 atomic_inc_64(&dlcosmk_data
->ipackets
);