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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2012, Nexenta Systems, Inc. All rights reserved.
29 #include <sys/sysmacros.h>
30 #include <sys/strsubr.h>
31 #include <sys/strsun.h>
33 #include <sys/dld_impl.h>
34 #include <sys/mac_client.h>
35 #include <sys/mac_client_impl.h>
36 #include <sys/mac_client_priv.h>
38 typedef void proto_reqfunc_t(dld_str_t
*, mblk_t
*);
40 static proto_reqfunc_t proto_info_req
, proto_attach_req
, proto_detach_req
,
41 proto_bind_req
, proto_unbind_req
, proto_promiscon_req
, proto_promiscoff_req
,
42 proto_enabmulti_req
, proto_disabmulti_req
, proto_physaddr_req
,
43 proto_setphysaddr_req
, proto_udqos_req
, proto_req
, proto_capability_req
,
44 proto_notify_req
, proto_passive_req
;
46 static void proto_capability_advertise(dld_str_t
*, mblk_t
*);
47 static int dld_capab_poll_disable(dld_str_t
*, dld_capab_poll_t
*);
48 static boolean_t
check_mod_above(queue_t
*, const char *);
50 #define DL_ACK_PENDING(state) \
51 ((state) == DL_ATTACH_PENDING || \
52 (state) == DL_DETACH_PENDING || \
53 (state) == DL_BIND_PENDING || \
54 (state) == DL_UNBIND_PENDING)
57 * Process a DLPI protocol message.
58 * The primitives DL_BIND_REQ, DL_ENABMULTI_REQ, DL_PROMISCON_REQ,
59 * DL_SET_PHYS_ADDR_REQ put the data link below our dld_str_t into an
60 * 'active' state. The primitive DL_PASSIVE_REQ marks our dld_str_t
61 * as 'passive' and forbids it from being subsequently made 'active'
62 * by the above primitives.
65 dld_proto(dld_str_t
*dsp
, mblk_t
*mp
)
69 if (MBLKL(mp
) < sizeof (t_uscalar_t
)) {
73 prim
= ((union DL_primitives
*)mp
->b_rptr
)->dl_primitive
;
77 proto_info_req(dsp
, mp
);
80 proto_bind_req(dsp
, mp
);
83 proto_unbind_req(dsp
, mp
);
86 proto_unitdata_req(dsp
, mp
);
89 proto_udqos_req(dsp
, mp
);
92 proto_attach_req(dsp
, mp
);
95 proto_detach_req(dsp
, mp
);
97 case DL_ENABMULTI_REQ
:
98 proto_enabmulti_req(dsp
, mp
);
100 case DL_DISABMULTI_REQ
:
101 proto_disabmulti_req(dsp
, mp
);
103 case DL_PROMISCON_REQ
:
104 proto_promiscon_req(dsp
, mp
);
106 case DL_PROMISCOFF_REQ
:
107 proto_promiscoff_req(dsp
, mp
);
109 case DL_PHYS_ADDR_REQ
:
110 proto_physaddr_req(dsp
, mp
);
112 case DL_SET_PHYS_ADDR_REQ
:
113 proto_setphysaddr_req(dsp
, mp
);
116 proto_notify_req(dsp
, mp
);
118 case DL_CAPABILITY_REQ
:
119 proto_capability_req(dsp
, mp
);
122 proto_passive_req(dsp
, mp
);
131 typedef struct dl_info_ack_wrapper
{
132 dl_info_ack_t dl_info
;
133 uint8_t dl_addr
[MAXMACADDRLEN
+ sizeof (uint16_t)];
134 uint8_t dl_brdcst_addr
[MAXMACADDRLEN
];
135 dl_qos_cl_range1_t dl_qos_range1
;
136 dl_qos_cl_sel1_t dl_qos_sel1
;
137 } dl_info_ack_wrapper_t
;
143 proto_info_req(dld_str_t
*dsp
, mblk_t
*mp
)
145 dl_info_ack_wrapper_t
*dlwp
;
147 dl_qos_cl_sel1_t
*selp
;
148 dl_qos_cl_range1_t
*rangep
;
150 uint8_t *brdcst_addr
;
155 queue_t
*q
= dsp
->ds_wq
;
158 * Swap the request message for one large enough to contain the
159 * wrapper structure defined above.
161 if ((mp
= mexchange(q
, mp
, sizeof (dl_info_ack_wrapper_t
),
162 M_PCPROTO
, 0)) == NULL
)
165 bzero(mp
->b_rptr
, sizeof (dl_info_ack_wrapper_t
));
166 dlwp
= (dl_info_ack_wrapper_t
*)mp
->b_rptr
;
168 dlp
= &(dlwp
->dl_info
);
169 ASSERT(dlp
== (dl_info_ack_t
*)mp
->b_rptr
);
171 dlp
->dl_primitive
= DL_INFO_ACK
;
174 * Set up the sub-structure pointers.
176 addr
= dlwp
->dl_addr
;
177 brdcst_addr
= dlwp
->dl_brdcst_addr
;
178 rangep
= &(dlwp
->dl_qos_range1
);
179 selp
= &(dlwp
->dl_qos_sel1
);
182 * This driver supports only version 2 connectionless DLPI provider
185 dlp
->dl_service_mode
= DL_CLDLS
;
186 dlp
->dl_version
= DL_VERSION_2
;
189 * Set the style of the provider
191 dlp
->dl_provider_style
= dsp
->ds_style
;
192 ASSERT(dlp
->dl_provider_style
== DL_STYLE1
||
193 dlp
->dl_provider_style
== DL_STYLE2
);
196 * Set the current DLPI state.
198 dlp
->dl_current_state
= dsp
->ds_dlstate
;
201 * Gratuitously set the media type. This is to deal with modules
202 * that assume the media type is known prior to DL_ATTACH_REQ
205 dlp
->dl_mac_type
= DL_ETHER
;
208 * If the stream is not at least attached we try to retrieve the
209 * mac_info using mac_info_get()
211 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
212 dsp
->ds_dlstate
== DL_ATTACH_PENDING
||
213 dsp
->ds_dlstate
== DL_DETACH_PENDING
) {
214 if (!mac_info_get(ddi_major_to_name(dsp
->ds_major
), &minfo
)) {
216 * Cannot find mac_info. giving up.
222 minfop
= (mac_info_t
*)dsp
->ds_mip
;
223 /* We can only get the sdu if we're attached. */
224 mac_sdu_get(dsp
->ds_mh
, &dlp
->dl_min_sdu
, &dlp
->dl_max_sdu
);
228 * Set the media type (properly this time).
231 dlp
->dl_mac_type
= minfop
->mi_nativemedia
;
233 dlp
->dl_mac_type
= minfop
->mi_media
;
236 * Set the DLSAP length. We only support 16 bit values and they
237 * appear after the MAC address portion of DLSAP addresses.
239 sap_length
= sizeof (uint16_t);
240 dlp
->dl_sap_length
= NEG(sap_length
);
242 addr_length
= minfop
->mi_addr_length
;
245 * Copy in the media broadcast address.
247 if (minfop
->mi_brdcst_addr
!= NULL
) {
248 dlp
->dl_brdcst_addr_offset
=
249 (uintptr_t)brdcst_addr
- (uintptr_t)dlp
;
250 bcopy(minfop
->mi_brdcst_addr
, brdcst_addr
, addr_length
);
251 dlp
->dl_brdcst_addr_length
= addr_length
;
254 /* Only VLAN links and links that have a normal tag mode support QOS. */
255 if ((dsp
->ds_mch
!= NULL
&&
256 mac_client_vid(dsp
->ds_mch
) != VLAN_ID_NONE
) ||
257 (dsp
->ds_dlp
!= NULL
&&
258 dsp
->ds_dlp
->dl_tagmode
== LINK_TAGMODE_NORMAL
)) {
259 dlp
->dl_qos_range_offset
= (uintptr_t)rangep
- (uintptr_t)dlp
;
260 dlp
->dl_qos_range_length
= sizeof (dl_qos_cl_range1_t
);
262 rangep
->dl_qos_type
= DL_QOS_CL_RANGE1
;
263 rangep
->dl_trans_delay
.dl_target_value
= DL_UNKNOWN
;
264 rangep
->dl_trans_delay
.dl_accept_value
= DL_UNKNOWN
;
265 rangep
->dl_protection
.dl_min
= DL_UNKNOWN
;
266 rangep
->dl_protection
.dl_max
= DL_UNKNOWN
;
267 rangep
->dl_residual_error
= DL_UNKNOWN
;
270 * Specify the supported range of priorities.
272 rangep
->dl_priority
.dl_min
= 0;
273 rangep
->dl_priority
.dl_max
= (1 << VLAN_PRI_SIZE
) - 1;
275 dlp
->dl_qos_offset
= (uintptr_t)selp
- (uintptr_t)dlp
;
276 dlp
->dl_qos_length
= sizeof (dl_qos_cl_sel1_t
);
278 selp
->dl_qos_type
= DL_QOS_CL_SEL1
;
279 selp
->dl_trans_delay
= DL_UNKNOWN
;
280 selp
->dl_protection
= DL_UNKNOWN
;
281 selp
->dl_residual_error
= DL_UNKNOWN
;
284 * Specify the current priority (which can be changed by
285 * the DL_UDQOS_REQ primitive).
287 selp
->dl_priority
= dsp
->ds_pri
;
290 dlp
->dl_addr_length
= addr_length
+ sizeof (uint16_t);
291 if (dsp
->ds_dlstate
== DL_IDLE
) {
293 * The stream is bound. Therefore we can formulate a valid
296 dlp
->dl_addr_offset
= (uintptr_t)addr
- (uintptr_t)dlp
;
298 mac_unicast_primary_get(dsp
->ds_mh
, addr
);
300 *(uint16_t *)(addr
+ addr_length
) = dsp
->ds_sap
;
304 IMPLY(dlp
->dl_qos_offset
!= 0, dlp
->dl_qos_length
!= 0);
305 IMPLY(dlp
->dl_qos_range_offset
!= 0,
306 dlp
->dl_qos_range_length
!= 0);
307 IMPLY(dlp
->dl_addr_offset
!= 0, dlp
->dl_addr_length
!= 0);
308 IMPLY(dlp
->dl_brdcst_addr_offset
!= 0,
309 dlp
->dl_brdcst_addr_length
!= 0);
318 proto_attach_req(dld_str_t
*dsp
, mblk_t
*mp
)
320 dl_attach_req_t
*dlp
= (dl_attach_req_t
*)mp
->b_rptr
;
323 queue_t
*q
= dsp
->ds_wq
;
325 if (MBLKL(mp
) < sizeof (dl_attach_req_t
) ||
326 dlp
->dl_ppa
< 0 || dsp
->ds_style
== DL_STYLE1
) {
331 if (dsp
->ds_dlstate
!= DL_UNATTACHED
) {
332 dl_err
= DL_OUTSTATE
;
336 dsp
->ds_dlstate
= DL_ATTACH_PENDING
;
338 err
= dld_str_attach(dsp
, dlp
->dl_ppa
);
349 dsp
->ds_dlstate
= DL_UNATTACHED
;
352 ASSERT(dsp
->ds_dlstate
== DL_UNBOUND
);
353 dlokack(q
, mp
, DL_ATTACH_REQ
);
357 dlerrorack(q
, mp
, DL_ATTACH_REQ
, dl_err
, (t_uscalar_t
)err
);
364 proto_detach_req(dld_str_t
*dsp
, mblk_t
*mp
)
366 queue_t
*q
= dsp
->ds_wq
;
369 if (MBLKL(mp
) < sizeof (dl_detach_req_t
)) {
374 if (dsp
->ds_dlstate
!= DL_UNBOUND
) {
375 dl_err
= DL_OUTSTATE
;
379 if (dsp
->ds_style
== DL_STYLE1
) {
384 ASSERT(dsp
->ds_datathr_cnt
== 0);
385 dsp
->ds_dlstate
= DL_DETACH_PENDING
;
388 dlokack(dsp
->ds_wq
, mp
, DL_DETACH_REQ
);
392 dlerrorack(q
, mp
, DL_DETACH_REQ
, dl_err
, 0);
399 proto_bind_req(dld_str_t
*dsp
, mblk_t
*mp
)
401 dl_bind_req_t
*dlp
= (dl_bind_req_t
*)mp
->b_rptr
;
403 uint8_t dlsap_addr
[MAXMACADDRLEN
+ sizeof (uint16_t)];
404 uint_t dlsap_addr_length
;
407 queue_t
*q
= dsp
->ds_wq
;
408 mac_perim_handle_t mph
;
412 if (MBLKL(mp
) < sizeof (dl_bind_req_t
)) {
417 if (dlp
->dl_xidtest_flg
!= 0) {
422 if (dlp
->dl_service_mode
!= DL_CLDLS
) {
423 dl_err
= DL_UNSUPPORTED
;
427 if (dsp
->ds_dlstate
!= DL_UNBOUND
) {
428 dl_err
= DL_OUTSTATE
;
432 mac_perim_enter_by_mh(dsp
->ds_mh
, &mph
);
434 if ((err
= dls_active_set(dsp
)) != 0) {
439 dsp
->ds_dlstate
= DL_BIND_PENDING
;
441 * Set the receive callback.
443 dls_rx_set(dsp
, (dsp
->ds_mode
== DLD_RAW
) ?
444 dld_str_rx_raw
: dld_str_rx_unitdata
, dsp
);
447 * Bind the channel such that it can receive packets.
450 dsp
->ds_nonip
= !check_mod_above(dsp
->ds_rq
, "ip") &&
451 !check_mod_above(dsp
->ds_rq
, "arp");
453 err
= dls_bind(dsp
, sap
);
465 dsp
->ds_dlstate
= DL_UNBOUND
;
466 dls_active_clear(dsp
, B_FALSE
);
470 intr_cpu
= mac_client_intr_cpu(dsp
->ds_mch
);
471 mdip
= mac_get_devinfo(dsp
->ds_mh
);
475 * We do this after we get out of the perim to avoid deadlocks
476 * etc. since part of mac_client_retarget_intr is to walk the
477 * device tree in order to find and retarget the interrupts.
480 mac_client_set_intr_cpu(mdip
, dsp
->ds_mch
, intr_cpu
);
483 * Copy in MAC address.
485 dlsap_addr_length
= dsp
->ds_mip
->mi_addr_length
;
486 mac_unicast_primary_get(dsp
->ds_mh
, dlsap_addr
);
491 *(uint16_t *)(dlsap_addr
+ dlsap_addr_length
) = sap
;
492 dlsap_addr_length
+= sizeof (uint16_t);
494 dsp
->ds_dlstate
= DL_IDLE
;
495 dlbindack(q
, mp
, sap
, dlsap_addr
, dlsap_addr_length
, 0, 0);
501 dlerrorack(q
, mp
, DL_BIND_REQ
, dl_err
, (t_uscalar_t
)err
);
508 proto_unbind_req(dld_str_t
*dsp
, mblk_t
*mp
)
510 queue_t
*q
= dsp
->ds_wq
;
512 mac_perim_handle_t mph
;
514 if (MBLKL(mp
) < sizeof (dl_unbind_req_t
)) {
519 if (dsp
->ds_dlstate
!= DL_IDLE
) {
520 dl_err
= DL_OUTSTATE
;
524 mutex_enter(&dsp
->ds_lock
);
525 while (dsp
->ds_datathr_cnt
!= 0)
526 cv_wait(&dsp
->ds_datathr_cv
, &dsp
->ds_lock
);
528 dsp
->ds_dlstate
= DL_UNBIND_PENDING
;
529 mutex_exit(&dsp
->ds_lock
);
531 mac_perim_enter_by_mh(dsp
->ds_mh
, &mph
);
533 * Unbind the channel to stop packets being received.
538 * Disable polling mode, if it is enabled.
540 (void) dld_capab_poll_disable(dsp
, NULL
);
545 dsp
->ds_lso
= B_FALSE
;
549 * Clear the receive callback.
551 dls_rx_set(dsp
, NULL
, NULL
);
552 dsp
->ds_direct
= B_FALSE
;
555 * Set the mode back to the default (unitdata).
557 dsp
->ds_mode
= DLD_UNITDATA
;
558 dsp
->ds_dlstate
= DL_UNBOUND
;
560 dls_active_clear(dsp
, B_FALSE
);
562 dlokack(dsp
->ds_wq
, mp
, DL_UNBIND_REQ
);
565 dlerrorack(q
, mp
, DL_UNBIND_REQ
, dl_err
, 0);
572 proto_promiscon_req(dld_str_t
*dsp
, mblk_t
*mp
)
574 dl_promiscon_req_t
*dlp
= (dl_promiscon_req_t
*)mp
->b_rptr
;
577 uint32_t new_flags
, promisc_saved
;
578 queue_t
*q
= dsp
->ds_wq
;
579 mac_perim_handle_t mph
;
581 if (MBLKL(mp
) < sizeof (dl_promiscon_req_t
)) {
586 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
587 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
588 dl_err
= DL_OUTSTATE
;
592 mac_perim_enter_by_mh(dsp
->ds_mh
, &mph
);
594 new_flags
= promisc_saved
= dsp
->ds_promisc
;
595 switch (dlp
->dl_level
) {
597 new_flags
|= DLS_PROMISC_SAP
;
600 case DL_PROMISC_MULTI
:
601 new_flags
|= DLS_PROMISC_MULTI
;
604 case DL_PROMISC_PHYS
:
605 new_flags
|= DLS_PROMISC_PHYS
;
609 dl_err
= DL_NOTSUPPORTED
;
613 if ((promisc_saved
== 0) && (err
= dls_active_set(dsp
)) != 0) {
614 ASSERT(dsp
->ds_promisc
== promisc_saved
);
620 * Adjust channel promiscuity.
622 err
= dls_promisc(dsp
, new_flags
);
626 dsp
->ds_promisc
= promisc_saved
;
627 if (promisc_saved
== 0)
628 dls_active_clear(dsp
, B_FALSE
);
634 dlokack(q
, mp
, DL_PROMISCON_REQ
);
640 dlerrorack(q
, mp
, DL_PROMISCON_REQ
, dl_err
, (t_uscalar_t
)err
);
647 proto_promiscoff_req(dld_str_t
*dsp
, mblk_t
*mp
)
649 dl_promiscoff_req_t
*dlp
= (dl_promiscoff_req_t
*)mp
->b_rptr
;
653 queue_t
*q
= dsp
->ds_wq
;
654 mac_perim_handle_t mph
;
656 if (MBLKL(mp
) < sizeof (dl_promiscoff_req_t
)) {
661 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
662 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
663 dl_err
= DL_OUTSTATE
;
667 mac_perim_enter_by_mh(dsp
->ds_mh
, &mph
);
669 new_flags
= dsp
->ds_promisc
;
670 switch (dlp
->dl_level
) {
672 if (!(dsp
->ds_promisc
& DLS_PROMISC_SAP
)) {
676 new_flags
&= ~DLS_PROMISC_SAP
;
679 case DL_PROMISC_MULTI
:
680 if (!(dsp
->ds_promisc
& DLS_PROMISC_MULTI
)) {
684 new_flags
&= ~DLS_PROMISC_MULTI
;
687 case DL_PROMISC_PHYS
:
688 if (!(dsp
->ds_promisc
& DLS_PROMISC_PHYS
)) {
692 new_flags
&= ~DLS_PROMISC_PHYS
;
696 dl_err
= DL_NOTSUPPORTED
;
701 * Adjust channel promiscuity.
703 err
= dls_promisc(dsp
, new_flags
);
711 ASSERT(dsp
->ds_promisc
== new_flags
);
712 if (dsp
->ds_promisc
== 0)
713 dls_active_clear(dsp
, B_FALSE
);
717 dlokack(q
, mp
, DL_PROMISCOFF_REQ
);
720 dlerrorack(q
, mp
, DL_PROMISCOFF_REQ
, dl_err
, (t_uscalar_t
)err
);
727 proto_enabmulti_req(dld_str_t
*dsp
, mblk_t
*mp
)
729 dl_enabmulti_req_t
*dlp
= (dl_enabmulti_req_t
*)mp
->b_rptr
;
732 queue_t
*q
= dsp
->ds_wq
;
733 mac_perim_handle_t mph
;
735 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
736 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
737 dl_err
= DL_OUTSTATE
;
741 if (MBLKL(mp
) < sizeof (dl_enabmulti_req_t
) ||
742 !MBLKIN(mp
, dlp
->dl_addr_offset
, dlp
->dl_addr_length
) ||
743 dlp
->dl_addr_length
!= dsp
->ds_mip
->mi_addr_length
) {
748 mac_perim_enter_by_mh(dsp
->ds_mh
, &mph
);
750 if ((dsp
->ds_dmap
== NULL
) && (err
= dls_active_set(dsp
)) != 0) {
755 err
= dls_multicst_add(dsp
, mp
->b_rptr
+ dlp
->dl_addr_offset
);
770 if (dsp
->ds_dmap
== NULL
)
771 dls_active_clear(dsp
, B_FALSE
);
777 dlokack(q
, mp
, DL_ENABMULTI_REQ
);
783 dlerrorack(q
, mp
, DL_ENABMULTI_REQ
, dl_err
, (t_uscalar_t
)err
);
790 proto_disabmulti_req(dld_str_t
*dsp
, mblk_t
*mp
)
792 dl_disabmulti_req_t
*dlp
= (dl_disabmulti_req_t
*)mp
->b_rptr
;
795 queue_t
*q
= dsp
->ds_wq
;
796 mac_perim_handle_t mph
;
798 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
799 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
800 dl_err
= DL_OUTSTATE
;
804 if (MBLKL(mp
) < sizeof (dl_disabmulti_req_t
) ||
805 !MBLKIN(mp
, dlp
->dl_addr_offset
, dlp
->dl_addr_length
) ||
806 dlp
->dl_addr_length
!= dsp
->ds_mip
->mi_addr_length
) {
811 mac_perim_enter_by_mh(dsp
->ds_mh
, &mph
);
812 err
= dls_multicst_remove(dsp
, mp
->b_rptr
+ dlp
->dl_addr_offset
);
813 if ((err
== 0) && (dsp
->ds_dmap
== NULL
))
814 dls_active_clear(dsp
, B_FALSE
);
835 dlokack(q
, mp
, DL_DISABMULTI_REQ
);
838 dlerrorack(q
, mp
, DL_DISABMULTI_REQ
, dl_err
, (t_uscalar_t
)err
);
845 proto_physaddr_req(dld_str_t
*dsp
, mblk_t
*mp
)
847 dl_phys_addr_req_t
*dlp
= (dl_phys_addr_req_t
*)mp
->b_rptr
;
848 queue_t
*q
= dsp
->ds_wq
;
849 t_uscalar_t dl_err
= 0;
853 if (MBLKL(mp
) < sizeof (dl_phys_addr_req_t
)) {
858 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
859 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
860 dl_err
= DL_OUTSTATE
;
864 addr_length
= dsp
->ds_mip
->mi_addr_length
;
865 if (addr_length
> 0) {
866 addr
= kmem_alloc(addr_length
, KM_SLEEP
);
867 switch (dlp
->dl_addr_type
) {
868 case DL_CURR_PHYS_ADDR
:
869 mac_unicast_primary_get(dsp
->ds_mh
, (uint8_t *)addr
);
871 case DL_FACT_PHYS_ADDR
:
872 bcopy(dsp
->ds_mip
->mi_unicst_addr
, addr
, addr_length
);
874 case DL_CURR_DEST_ADDR
:
875 if (!mac_dst_get(dsp
->ds_mh
, (uint8_t *)addr
))
876 dl_err
= DL_NOTSUPPORTED
;
879 dl_err
= DL_UNSUPPORTED
;
884 dlphysaddrack(q
, mp
, addr
, (t_uscalar_t
)addr_length
);
886 dlerrorack(q
, mp
, DL_PHYS_ADDR_REQ
, dl_err
, 0);
888 kmem_free(addr
, addr_length
);
892 * DL_SET_PHYS_ADDR_REQ
895 proto_setphysaddr_req(dld_str_t
*dsp
, mblk_t
*mp
)
897 dl_set_phys_addr_req_t
*dlp
= (dl_set_phys_addr_req_t
*)mp
->b_rptr
;
900 queue_t
*q
= dsp
->ds_wq
;
901 mac_perim_handle_t mph
;
903 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
904 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
905 dl_err
= DL_OUTSTATE
;
909 if (MBLKL(mp
) < sizeof (dl_set_phys_addr_req_t
) ||
910 !MBLKIN(mp
, dlp
->dl_addr_offset
, dlp
->dl_addr_length
) ||
911 dlp
->dl_addr_length
!= dsp
->ds_mip
->mi_addr_length
) {
916 mac_perim_enter_by_mh(dsp
->ds_mh
, &mph
);
918 if ((err
= dls_active_set(dsp
)) != 0) {
924 * If mac-nospoof is enabled and the link is owned by a
925 * non-global zone, changing the mac address is not allowed.
927 if (dsp
->ds_dlp
->dl_zid
!= GLOBAL_ZONEID
&&
928 mac_protect_enabled(dsp
->ds_mch
, MPT_MACNOSPOOF
)) {
929 dls_active_clear(dsp
, B_FALSE
);
934 err
= mac_unicast_primary_set(dsp
->ds_mh
,
935 mp
->b_rptr
+ dlp
->dl_addr_offset
);
947 dls_active_clear(dsp
, B_FALSE
);
954 dlokack(q
, mp
, DL_SET_PHYS_ADDR_REQ
);
960 dlerrorack(q
, mp
, DL_SET_PHYS_ADDR_REQ
, dl_err
, (t_uscalar_t
)err
);
967 proto_udqos_req(dld_str_t
*dsp
, mblk_t
*mp
)
969 dl_udqos_req_t
*dlp
= (dl_udqos_req_t
*)mp
->b_rptr
;
970 dl_qos_cl_sel1_t
*selp
;
973 queue_t
*q
= dsp
->ds_wq
;
975 off
= dlp
->dl_qos_offset
;
976 len
= dlp
->dl_qos_length
;
978 if (MBLKL(mp
) < sizeof (dl_udqos_req_t
) || !MBLKIN(mp
, off
, len
)) {
983 selp
= (dl_qos_cl_sel1_t
*)(mp
->b_rptr
+ off
);
984 if (selp
->dl_qos_type
!= DL_QOS_CL_SEL1
) {
985 dl_err
= DL_BADQOSTYPE
;
989 if (selp
->dl_priority
> (1 << VLAN_PRI_SIZE
) - 1 ||
990 selp
->dl_priority
< 0) {
991 dl_err
= DL_BADQOSPARAM
;
995 dsp
->ds_pri
= selp
->dl_priority
;
996 dlokack(q
, mp
, DL_UDQOS_REQ
);
999 dlerrorack(q
, mp
, DL_UDQOS_REQ
, dl_err
, 0);
1003 check_mod_above(queue_t
*q
, const char *mod
)
1006 boolean_t ret
= B_TRUE
;
1010 if (strcmp(next_q
->q_qinfo
->qi_minfo
->mi_idname
, mod
) != 0)
1020 proto_capability_req(dld_str_t
*dsp
, mblk_t
*mp
)
1022 dl_capability_req_t
*dlp
= (dl_capability_req_t
*)mp
->b_rptr
;
1023 dl_capability_sub_t
*sp
;
1027 queue_t
*q
= dsp
->ds_wq
;
1029 if (MBLKL(mp
) < sizeof (dl_capability_req_t
)) {
1030 dl_err
= DL_BADPRIM
;
1034 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
1035 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
1036 dl_err
= DL_OUTSTATE
;
1041 * This request is overloaded. If there are no requested capabilities
1042 * then we just want to acknowledge with all the capabilities we
1043 * support. Otherwise we enable the set of capabilities requested.
1045 if (dlp
->dl_sub_length
== 0) {
1046 proto_capability_advertise(dsp
, mp
);
1050 if (!MBLKIN(mp
, dlp
->dl_sub_offset
, dlp
->dl_sub_length
)) {
1051 dl_err
= DL_BADPRIM
;
1055 dlp
->dl_primitive
= DL_CAPABILITY_ACK
;
1057 off
= dlp
->dl_sub_offset
;
1058 len
= dlp
->dl_sub_length
;
1061 * Walk the list of capabilities to be enabled.
1063 for (end
= off
+ len
; off
< end
; ) {
1064 sp
= (dl_capability_sub_t
*)(mp
->b_rptr
+ off
);
1065 size
= sizeof (dl_capability_sub_t
) + sp
->dl_length
;
1067 if (off
+ size
> end
||
1068 !IS_P2ALIGNED(off
, sizeof (uint32_t))) {
1069 dl_err
= DL_BADPRIM
;
1073 switch (sp
->dl_cap
) {
1075 * TCP/IP checksum offload to hardware.
1077 case DL_CAPAB_HCKSUM
: {
1078 dl_capab_hcksum_t
*hcksump
;
1079 dl_capab_hcksum_t hcksum
;
1081 hcksump
= (dl_capab_hcksum_t
*)&sp
[1];
1083 * Copy for alignment.
1085 bcopy(hcksump
, &hcksum
, sizeof (dl_capab_hcksum_t
));
1086 dlcapabsetqid(&(hcksum
.hcksum_mid
), dsp
->ds_rq
);
1087 bcopy(&hcksum
, hcksump
, sizeof (dl_capab_hcksum_t
));
1091 case DL_CAPAB_DLD
: {
1092 dl_capab_dld_t
*dldp
;
1095 dldp
= (dl_capab_dld_t
*)&sp
[1];
1097 * Copy for alignment.
1099 bcopy(dldp
, &dld
, sizeof (dl_capab_dld_t
));
1100 dlcapabsetqid(&(dld
.dld_mid
), dsp
->ds_rq
);
1101 bcopy(&dld
, dldp
, sizeof (dl_capab_dld_t
));
1112 dlerrorack(q
, mp
, DL_CAPABILITY_REQ
, dl_err
, 0);
1119 proto_notify_req(dld_str_t
*dsp
, mblk_t
*mp
)
1121 dl_notify_req_t
*dlp
= (dl_notify_req_t
*)mp
->b_rptr
;
1123 queue_t
*q
= dsp
->ds_wq
;
1125 DL_NOTE_PROMISC_ON_PHYS
|
1126 DL_NOTE_PROMISC_OFF_PHYS
|
1130 DL_NOTE_CAPAB_RENEG
|
1131 DL_NOTE_FASTPATH_FLUSH
|
1135 DL_NOTE_ALLOWED_IPS
;
1137 if (MBLKL(mp
) < sizeof (dl_notify_req_t
)) {
1138 dl_err
= DL_BADPRIM
;
1142 if (dsp
->ds_dlstate
== DL_UNATTACHED
||
1143 DL_ACK_PENDING(dsp
->ds_dlstate
)) {
1144 dl_err
= DL_OUTSTATE
;
1148 note
&= ~(mac_no_notification(dsp
->ds_mh
));
1151 * Cache the notifications that are being enabled.
1153 dsp
->ds_notifications
= dlp
->dl_notifications
& note
;
1155 * The ACK carries all notifications regardless of which set is
1158 dlnotifyack(q
, mp
, note
);
1161 * Generate DL_NOTIFY_IND messages for each enabled notification.
1163 if (dsp
->ds_notifications
!= 0) {
1164 dld_str_notify_ind(dsp
);
1168 dlerrorack(q
, mp
, DL_NOTIFY_REQ
, dl_err
, 0);
1175 proto_unitdata_req(dld_str_t
*dsp
, mblk_t
*mp
)
1177 queue_t
*q
= dsp
->ds_wq
;
1178 dl_unitdata_req_t
*dlp
= (dl_unitdata_req_t
*)mp
->b_rptr
;
1181 const uint8_t *addr
;
1184 mblk_t
*bp
, *payload
;
1185 uint32_t start
, stuff
, end
, value
, flags
;
1189 if (MBLKL(mp
) < sizeof (dl_unitdata_req_t
) || mp
->b_cont
== NULL
) {
1190 dlerrorack(q
, mp
, DL_UNITDATA_REQ
, DL_BADPRIM
, 0);
1194 mutex_enter(&dsp
->ds_lock
);
1195 if (dsp
->ds_dlstate
!= DL_IDLE
) {
1196 mutex_exit(&dsp
->ds_lock
);
1197 dlerrorack(q
, mp
, DL_UNITDATA_REQ
, DL_OUTSTATE
, 0);
1200 DLD_DATATHR_INC(dsp
);
1201 mutex_exit(&dsp
->ds_lock
);
1203 addr_length
= dsp
->ds_mip
->mi_addr_length
;
1205 off
= dlp
->dl_dest_addr_offset
;
1206 len
= dlp
->dl_dest_addr_length
;
1208 if (!MBLKIN(mp
, off
, len
) || !IS_P2ALIGNED(off
, sizeof (uint16_t))) {
1209 dl_err
= DL_BADPRIM
;
1213 if (len
!= addr_length
+ sizeof (uint16_t)) {
1214 dl_err
= DL_BADADDR
;
1218 addr
= mp
->b_rptr
+ off
;
1219 sap
= *(uint16_t *)(mp
->b_rptr
+ off
+ addr_length
);
1222 * Check the length of the packet and the block types.
1225 payload
= mp
->b_cont
;
1226 for (bp
= payload
; bp
!= NULL
; bp
= bp
->b_cont
) {
1227 if (DB_TYPE(bp
) != M_DATA
)
1233 mac_sdu_get(dsp
->ds_mh
, NULL
, &max_sdu
);
1238 * Build a packet header.
1240 if ((bp
= dls_header(dsp
, addr
, sap
, dlp
->dl_priority
.dl_max
,
1241 &payload
)) == NULL
) {
1242 dl_err
= DL_BADADDR
;
1247 * We no longer need the M_PROTO header, so free it.
1252 * Transfer the checksum offload information if it is present.
1254 hcksum_retrieve(payload
, NULL
, NULL
, &start
, &stuff
, &end
, &value
,
1256 (void) hcksum_assoc(bp
, NULL
, NULL
, start
, stuff
, end
, value
, flags
, 0);
1259 * Link the payload onto the new header.
1261 ASSERT(bp
->b_cont
== NULL
);
1262 bp
->b_cont
= payload
;
1265 * No lock can be held across modules and putnext()'s,
1266 * which can happen here with the call from DLD_TX().
1268 if (DLD_TX(dsp
, bp
, 0, 0) != NULL
) {
1269 /* flow-controlled */
1272 DLD_DATATHR_DCR(dsp
);
1276 dlerrorack(q
, mp
, DL_UNITDATA_REQ
, dl_err
, 0);
1277 DLD_DATATHR_DCR(dsp
);
1281 dluderrorind(q
, mp
, (void *)addr
, len
, DL_BADDATA
, 0);
1282 DLD_DATATHR_DCR(dsp
);
1289 proto_passive_req(dld_str_t
*dsp
, mblk_t
*mp
)
1294 * If we've already become active by issuing an active primitive,
1295 * then it's too late to try to become passive.
1297 if (dsp
->ds_passivestate
== DLD_ACTIVE
) {
1298 dl_err
= DL_OUTSTATE
;
1302 if (MBLKL(mp
) < sizeof (dl_passive_req_t
)) {
1303 dl_err
= DL_BADPRIM
;
1307 dsp
->ds_passivestate
= DLD_PASSIVE
;
1308 dlokack(dsp
->ds_wq
, mp
, DL_PASSIVE_REQ
);
1311 dlerrorack(dsp
->ds_wq
, mp
, DL_PASSIVE_REQ
, dl_err
, 0);
1316 * Catch-all handler.
1319 proto_req(dld_str_t
*dsp
, mblk_t
*mp
)
1321 union DL_primitives
*dlp
= (union DL_primitives
*)mp
->b_rptr
;
1323 dlerrorack(dsp
->ds_wq
, mp
, dlp
->dl_primitive
, DL_UNSUPPORTED
, 0);
1327 dld_capab_perim(dld_str_t
*dsp
, void *data
, uint_t flags
)
1331 mac_perim_enter_by_mh(dsp
->ds_mh
, (mac_perim_handle_t
*)data
);
1335 mac_perim_exit((mac_perim_handle_t
)data
);
1339 return (mac_perim_held(dsp
->ds_mh
));
1345 dld_capab_direct(dld_str_t
*dsp
, void *data
, uint_t flags
)
1347 dld_capab_direct_t
*direct
= data
;
1349 ASSERT(MAC_PERIM_HELD(dsp
->ds_mh
));
1353 dls_rx_set(dsp
, (dls_rx_t
)direct
->di_rx_cf
,
1356 direct
->di_tx_df
= (uintptr_t)str_mdata_fastpath_put
;
1357 direct
->di_tx_dh
= dsp
;
1358 direct
->di_tx_cb_df
= (uintptr_t)mac_client_tx_notify
;
1359 direct
->di_tx_cb_dh
= dsp
->ds_mch
;
1360 direct
->di_tx_fctl_df
= (uintptr_t)mac_tx_is_flow_blocked
;
1361 direct
->di_tx_fctl_dh
= dsp
->ds_mch
;
1363 dsp
->ds_direct
= B_TRUE
;
1368 dls_rx_set(dsp
, (dsp
->ds_mode
== DLD_FASTPATH
) ?
1369 dld_str_rx_fastpath
: dld_str_rx_unitdata
, (void *)dsp
);
1370 dsp
->ds_direct
= B_FALSE
;
1378 * dld_capab_poll_enable()
1380 * This function is misnamed. All polling and fanouts are run out of the
1381 * lower mac (in case of VNIC and the only mac in case of NICs). The
1382 * availability of Rx ring and promiscous mode is all taken care between
1383 * the soft ring set (mac_srs), the Rx ring, and S/W classifier. Any
1384 * fanout necessary is done by the soft rings that are part of the
1385 * mac_srs (by default mac_srs sends the packets up via a TCP and
1386 * non TCP soft ring).
1388 * The mac_srs (or its associated soft rings) always store the ill_rx_ring
1389 * (the cookie returned when they registered with IP during plumb) as their
1390 * 2nd argument which is passed up as mac_resource_handle_t. The upcall
1391 * function and 1st argument is what the caller registered when they
1392 * called mac_rx_classify_flow_add() to register the flow. For VNIC,
1393 * the function is vnic_rx and argument is vnic_t. For regular NIC
1394 * case, it mac_rx_default and mac_handle_t. As explained above, the
1395 * mac_srs (or its soft ring) will add the ill_rx_ring (mac_resource_handle_t)
1396 * from its stored 2nd argument.
1399 dld_capab_poll_enable(dld_str_t
*dsp
, dld_capab_poll_t
*poll
)
1401 if (dsp
->ds_polling
)
1404 if ((dld_opt
& DLD_OPT_NO_POLL
) != 0 || dsp
->ds_mode
== DLD_RAW
)
1408 * Enable client polling if and only if DLS bypass is possible.
1409 * Special cases like VLANs need DLS processing in the Rx data path.
1410 * In such a case we can neither allow the client (IP) to directly
1411 * poll the softring (since DLS processing hasn't been done) nor can
1412 * we allow DLS bypass.
1414 if (!mac_rx_bypass_set(dsp
->ds_mch
, dsp
->ds_rx
, dsp
->ds_rx_arg
))
1418 * Register soft ring resources. This will come in handy later if
1419 * the user decides to modify CPU bindings to use more CPUs for the
1420 * device in which case we will switch to fanout using soft rings.
1422 mac_resource_set_common(dsp
->ds_mch
,
1423 (mac_resource_add_t
)poll
->poll_ring_add_cf
,
1424 (mac_resource_remove_t
)poll
->poll_ring_remove_cf
,
1425 (mac_resource_quiesce_t
)poll
->poll_ring_quiesce_cf
,
1426 (mac_resource_restart_t
)poll
->poll_ring_restart_cf
,
1427 (mac_resource_bind_t
)poll
->poll_ring_bind_cf
,
1428 poll
->poll_ring_ch
);
1430 mac_client_poll_enable(dsp
->ds_mch
);
1432 dsp
->ds_polling
= B_TRUE
;
1438 dld_capab_poll_disable(dld_str_t
*dsp
, dld_capab_poll_t
*poll
)
1440 if (!dsp
->ds_polling
)
1443 mac_client_poll_disable(dsp
->ds_mch
);
1444 mac_resource_set(dsp
->ds_mch
, NULL
, NULL
);
1446 dsp
->ds_polling
= B_FALSE
;
1451 dld_capab_poll(dld_str_t
*dsp
, void *data
, uint_t flags
)
1453 dld_capab_poll_t
*poll
= data
;
1455 ASSERT(MAC_PERIM_HELD(dsp
->ds_mh
));
1459 return (dld_capab_poll_enable(dsp
, poll
));
1461 return (dld_capab_poll_disable(dsp
, poll
));
1467 dld_capab_lso(dld_str_t
*dsp
, void *data
, uint_t flags
)
1469 dld_capab_lso_t
*lso
= data
;
1471 ASSERT(MAC_PERIM_HELD(dsp
->ds_mh
));
1475 mac_capab_lso_t mac_lso
;
1478 * Check if LSO is supported on this MAC & enable LSO
1481 if (mac_capab_get(dsp
->ds_mh
, MAC_CAPAB_LSO
, &mac_lso
)) {
1482 lso
->lso_max
= mac_lso
.lso_basic_tcp_ipv4
.lso_max
;
1484 /* translate the flag for mac clients */
1485 if ((mac_lso
.lso_flags
& LSO_TX_BASIC_TCP_IPV4
) != 0)
1486 lso
->lso_flags
|= DLD_LSO_BASIC_TCP_IPV4
;
1487 dsp
->ds_lso
= B_TRUE
;
1488 dsp
->ds_lso_max
= lso
->lso_max
;
1490 dsp
->ds_lso
= B_FALSE
;
1491 dsp
->ds_lso_max
= 0;
1497 dsp
->ds_lso
= B_FALSE
;
1498 dsp
->ds_lso_max
= 0;
1506 dld_capab(dld_str_t
*dsp
, uint_t type
, void *data
, uint_t flags
)
1511 * Don't enable direct callback capabilities unless the caller is
1512 * the IP client. When a module is inserted in a stream (_I_INSERT)
1513 * the stack initiates capability disable, but due to races, the
1514 * module insertion may complete before the capability disable
1515 * completes. So we limit the check to DLD_ENABLE case.
1517 if ((flags
== DLD_ENABLE
&& type
!= DLD_CAPAB_PERIM
) &&
1518 (dsp
->ds_sap
!= ETHERTYPE_IP
||
1519 !check_mod_above(dsp
->ds_rq
, "ip"))) {
1524 case DLD_CAPAB_DIRECT
:
1525 err
= dld_capab_direct(dsp
, data
, flags
);
1528 case DLD_CAPAB_POLL
:
1529 err
= dld_capab_poll(dsp
, data
, flags
);
1532 case DLD_CAPAB_PERIM
:
1533 err
= dld_capab_perim(dsp
, data
, flags
);
1537 err
= dld_capab_lso(dsp
, data
, flags
);
1549 * DL_CAPABILITY_ACK/DL_ERROR_ACK
1552 proto_capability_advertise(dld_str_t
*dsp
, mblk_t
*mp
)
1554 dl_capability_ack_t
*dlap
;
1555 dl_capability_sub_t
*dlsp
;
1558 dl_capab_hcksum_t hcksum
;
1559 dl_capab_zerocopy_t zcopy
;
1560 dl_capab_vrrp_t vrrp
;
1561 mac_capab_vrrp_t vrrp_capab
;
1563 queue_t
*q
= dsp
->ds_wq
;
1565 boolean_t hcksum_capable
= B_FALSE
;
1566 boolean_t zcopy_capable
= B_FALSE
;
1567 boolean_t dld_capable
= B_FALSE
;
1568 boolean_t vrrp_capable
= B_FALSE
;
1571 * Initially assume no capabilities.
1576 * Check if checksum offload is supported on this MAC.
1578 bzero(&hcksum
, sizeof (dl_capab_hcksum_t
));
1579 if (mac_capab_get(dsp
->ds_mh
, MAC_CAPAB_HCKSUM
,
1580 &hcksum
.hcksum_txflags
)) {
1581 if (hcksum
.hcksum_txflags
!= 0) {
1582 hcksum_capable
= B_TRUE
;
1583 subsize
+= sizeof (dl_capability_sub_t
) +
1584 sizeof (dl_capab_hcksum_t
);
1589 * Check if zerocopy is supported on this interface.
1590 * If advertising DL_CAPAB_ZEROCOPY has not been explicitly disabled
1591 * then reserve space for that capability.
1593 if (!mac_capab_get(dsp
->ds_mh
, MAC_CAPAB_NO_ZCOPY
, NULL
) &&
1594 !(dld_opt
& DLD_OPT_NO_ZEROCOPY
)) {
1595 zcopy_capable
= B_TRUE
;
1596 subsize
+= sizeof (dl_capability_sub_t
) +
1597 sizeof (dl_capab_zerocopy_t
);
1601 * Direct capability negotiation interface between IP and DLD
1603 if (dsp
->ds_sap
== ETHERTYPE_IP
&& check_mod_above(dsp
->ds_rq
, "ip")) {
1604 dld_capable
= B_TRUE
;
1605 subsize
+= sizeof (dl_capability_sub_t
) +
1606 sizeof (dl_capab_dld_t
);
1610 * Check if vrrp is supported on this interface. If so, reserve
1611 * space for that capability.
1613 if (mac_capab_get(dsp
->ds_mh
, MAC_CAPAB_VRRP
, &vrrp_capab
)) {
1614 vrrp_capable
= B_TRUE
;
1615 subsize
+= sizeof (dl_capability_sub_t
) +
1616 sizeof (dl_capab_vrrp_t
);
1620 * If there are no capabilities to advertise or if we
1621 * can't allocate a response, send a DL_ERROR_ACK.
1623 if ((mp1
= reallocb(mp
,
1624 sizeof (dl_capability_ack_t
) + subsize
, 0)) == NULL
) {
1625 dlerrorack(q
, mp
, DL_CAPABILITY_REQ
, DL_NOTSUPPORTED
, 0);
1630 DB_TYPE(mp
) = M_PROTO
;
1631 mp
->b_wptr
= mp
->b_rptr
+ sizeof (dl_capability_ack_t
) + subsize
;
1632 bzero(mp
->b_rptr
, MBLKL(mp
));
1633 dlap
= (dl_capability_ack_t
*)mp
->b_rptr
;
1634 dlap
->dl_primitive
= DL_CAPABILITY_ACK
;
1635 dlap
->dl_sub_offset
= sizeof (dl_capability_ack_t
);
1636 dlap
->dl_sub_length
= subsize
;
1637 ptr
= (uint8_t *)&dlap
[1];
1640 * TCP/IP checksum offload.
1642 if (hcksum_capable
) {
1643 dlsp
= (dl_capability_sub_t
*)ptr
;
1645 dlsp
->dl_cap
= DL_CAPAB_HCKSUM
;
1646 dlsp
->dl_length
= sizeof (dl_capab_hcksum_t
);
1647 ptr
+= sizeof (dl_capability_sub_t
);
1649 hcksum
.hcksum_version
= HCKSUM_VERSION_1
;
1650 dlcapabsetqid(&(hcksum
.hcksum_mid
), dsp
->ds_rq
);
1651 bcopy(&hcksum
, ptr
, sizeof (dl_capab_hcksum_t
));
1652 ptr
+= sizeof (dl_capab_hcksum_t
);
1658 if (zcopy_capable
) {
1659 dlsp
= (dl_capability_sub_t
*)ptr
;
1661 dlsp
->dl_cap
= DL_CAPAB_ZEROCOPY
;
1662 dlsp
->dl_length
= sizeof (dl_capab_zerocopy_t
);
1663 ptr
+= sizeof (dl_capability_sub_t
);
1665 bzero(&zcopy
, sizeof (dl_capab_zerocopy_t
));
1666 zcopy
.zerocopy_version
= ZEROCOPY_VERSION_1
;
1667 zcopy
.zerocopy_flags
= DL_CAPAB_VMSAFE_MEM
;
1669 dlcapabsetqid(&(zcopy
.zerocopy_mid
), dsp
->ds_rq
);
1670 bcopy(&zcopy
, ptr
, sizeof (dl_capab_zerocopy_t
));
1671 ptr
+= sizeof (dl_capab_zerocopy_t
);
1675 * VRRP capability negotiation
1678 dlsp
= (dl_capability_sub_t
*)ptr
;
1679 dlsp
->dl_cap
= DL_CAPAB_VRRP
;
1680 dlsp
->dl_length
= sizeof (dl_capab_vrrp_t
);
1681 ptr
+= sizeof (dl_capability_sub_t
);
1683 bzero(&vrrp
, sizeof (dl_capab_vrrp_t
));
1684 vrrp
.vrrp_af
= vrrp_capab
.mcv_af
;
1685 bcopy(&vrrp
, ptr
, sizeof (dl_capab_vrrp_t
));
1686 ptr
+= sizeof (dl_capab_vrrp_t
);
1690 * Direct capability negotiation interface between IP and DLD.
1691 * Refer to dld.h for details.
1694 dlsp
= (dl_capability_sub_t
*)ptr
;
1695 dlsp
->dl_cap
= DL_CAPAB_DLD
;
1696 dlsp
->dl_length
= sizeof (dl_capab_dld_t
);
1697 ptr
+= sizeof (dl_capability_sub_t
);
1699 bzero(&dld
, sizeof (dl_capab_dld_t
));
1700 dld
.dld_version
= DLD_CURRENT_VERSION
;
1701 dld
.dld_capab
= (uintptr_t)dld_capab
;
1702 dld
.dld_capab_handle
= (uintptr_t)dsp
;
1704 dlcapabsetqid(&(dld
.dld_mid
), dsp
->ds_rq
);
1705 bcopy(&dld
, ptr
, sizeof (dl_capab_dld_t
));
1706 ptr
+= sizeof (dl_capab_dld_t
);
1709 ASSERT(ptr
== mp
->b_rptr
+ sizeof (dl_capability_ack_t
) + subsize
);
1714 * Disable any enabled capabilities.
1717 dld_capabilities_disable(dld_str_t
*dsp
)
1719 if (dsp
->ds_polling
)
1720 (void) dld_capab_poll_disable(dsp
, NULL
);