2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2016 Joyent, Inc.
19 .Nd transmit a message block chain
21 .In sys/mac_provider.h
25 .Fa "mblk_t *mp_chain"
32 A pointer to the driver's private data that was passed in via the
42 structures that may have multiple independent packets linked together on
50 entry point is called when the system requires a device driver to
52 The device driver will receive a chain of message blocks.
55 argument represents the first frame.
56 The frame may be spread out across one or more
58 structures that are linked together by the
61 There may be multiple frames, linked together by the
66 For each frame, the driver should allocate the required resources and
67 prepare it for being transmitted on the wire.
68 The driver may opt to copy those resources to a DMA buffer or it may bind them.
69 For more information on these options, see the
74 As it processes each frame in the chain, if the device driver has
75 advertised either of the
79 flags, it must check whether either apply for the given frame using the
83 functions respectively.
84 If either is enabled for the given frame, the hardware must arrange for that to
87 For each frame that the device driver processes it is responsible for
88 doing one of three things with it:
93 Drop the frame by calling
95 on the individual mblk_t.
97 Return the frames to indicate that resources are not available.
100 The device driver is in charge of the memory associated with
102 If the device driver does not return the message blocks to the GLDv3,
106 If it does not, the memory associated with them will be leaked.
107 When a frame is being transmitted, if the device driver performed DMA binding,
108 it should not free the message block until after it is guaranteed that the frame
109 has been transmitted.
110 If the message block was copied to a DMA buffer, then it is allowed to call
114 In general, the device driver should not drop frames without
115 transmitting them unless it has no other choice.
116 Times when this happens may include the device driver being in a state where it
117 can't transmit, an error was found in the frame while trying to establish the
118 checksum or LSO state, or some other kind of error that represents an issue with
121 The device driver should not free the chain when it does not have enough
123 For example, if entries in a device's descriptor ring fill up, then it should
124 not drop those frames and instead should return all of the frames that were not
126 This indicates to the stack that the device is full and that flow control should
128 Back pressure will be applied to the rest of the stack, allowing most systems
131 Once a device driver has returned unprocessed frames from its
133 entry point, then the device driver will not receive any additional
136 entry point until it calls
138 to indicate that resources are available again.
139 Note that because it is the device driver that is calling this function to
140 indicate resources are available, it is very important that it only return
141 frames in cases where the device driver itself will be notified that resources
143 For example, when it receives an interrupt indicating that the data that it
144 transmitted has been completed so it can use entries in its descriptor ring or
145 other data structures again.
147 The device driver can obtain access to its soft state through the
150 It should cast it to the appropriate structure.
151 The device driver should employ any necessary locking to access the transmit
152 related data structures.
153 Note that the device driver should expect that it may have its transmit
154 endpoints called into from other threads while it's servicing device interrupts
159 entry point may be called from
165 Upon successful completion, the device driver should return
167 Otherwise, it should return all unprocessed message blocks and ensure
170 some time in the future.
175 .Xr mac_register 9F ,
176 .Xr mac_tx_update 9F ,
177 .Xr mac_register 9S ,