1502 Remove conversion cruft from manpages
[unleashed.git] / usr / src / man / man9e / gld.9e
blob7e6c4636347fbe45de764fbd1f6db7ae9f1b7d47
1 '\" te
2 .\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH GLD 9E "Jan 3, 2001"
7 .SH NAME
8 gld, gldm_reset, gldm_start, gldm_stop, gldm_set_mac_addr, gldm_set_multicast,
9 gldm_set_promiscuous, gldm_send, gldm_intr, gldm_get_stats, gldm_ioctl \-
10 Generic LAN Driver entry points
11 .SH SYNOPSIS
12 .LP
13 .nf
14 #include <sys/gld.h>
16 \fBint\fR \fBprefix_reset\fR(\fBgld_mac_info_t *\fR\fImacinfo\fR);
17 .fi
19 .LP
20 .nf
21 \fBint\fR \fBprefix_start\fR(\fBgld_mac_info_t *\fR\fImacinfo\fR);
22 .fi
24 .LP
25 .nf
26 \fBint\fR \fBprefix_stop\fR(\fBgld_mac_info_t *\fR
27      \fImacinfo\fR);
28 .fi
30 .LP
31 .nf
32 \fBint\fR \fBprefix_set_mac_addr\fR(\fBgld_mac_info_t *\fR
33      \fImacinfo\fR, \fBunsigned char *\fR\fImacaddr\fR);
34 .fi
36 .LP
37 .nf
38 \fBint\fR \fBprefix_set_multicast\fR(\fBgld_mac_info_t *\fR
39      \fImacinfo\fR, \fBunsigned char *\fR\fImulticastaddr\fR,
40      \fBint\fR \fImultiflag\fR);
41 .fi
43 .LP
44 .nf
45 \fBint\fR \fBprefix_set_promiscuous\fR(\fBgld_mac_info_t *\fR\fImacinfo\fR,
46       \fBint\fR \fIpromiscflag\fR);
47 .fi
49 .LP
50 .nf
51 \fBint\fR \fBprefix_send\fR(\fBgld_mac_info_t *\fR\fImacinfo\fR,
52      \fBmblk_t *\fR\fImp\fR);
53 .fi
55 .LP
56 .nf
57 \fBuint_t\fR \fBprefix_intr\fR(\fBgld_mac_info_t *\fR\fImacinfo\fR);
58 .fi
60 .LP
61 .nf
62 \fBint\fR \fBprefix_get_stats\fR(\fBgld_mac_info_t *\fR\fImacinfo\fR,
63      \fBstruct gld_stats *\fR\fIstats\fR);
64 .fi
66 .LP
67 .nf
68 \fBint\fR \fBprefix_ioctl\fR(\fBgld_mac_info_t *\fR\fImacinfo\fR,
69      \fBqueue_t *\fR\fIq\fR, \fBmblk_t *\fR\fImp\fR);
70 .fi
72 .SH INTERFACE LEVEL
73 .sp
74 .LP
75 Solaris architecture specific (Solaris DDI).
76 .SH PARAMETERS
77 .sp
78 .ne 2
79 .na
80 \fB\fImacinfo\fR \fR
81 .ad
82 .RS 18n
83 Pointer to a \fBgld_mac_info\fR(9S) structure.
84 .RE
86 .sp
87 .ne 2
88 .na
89 \fB\fImacaddr\fR \fR
90 .ad
91 .RS 18n
92 Pointer to the beginning of a character array containing a valid MAC address.
93 The array will be of the length specified by the driver in the
94 \fBgldm_addrlen\fR element of the \fBgld_mac_info\fR(9S) structure.
95 .RE
97 .sp
98 .ne 2
99 .na
100 \fB\fImulticastaddr\fR \fR
102 .RS 18n
103 Pointer to the beginning of a character array containing a multicast, group, or
104 functional address. The array will be of the length specified by the driver in
105 the \fBgldm_addrlen\fR element of the \fBgld_mac_info\fR(9S) structure.
109 .ne 2
111 \fB\fImultiflag\fR \fR
113 .RS 18n
114 A flag indicating whether reception of the multicast address is to be enabled
115 or disabled. This argument is specified as \fBGLD_MULTI_ENABLE\fR or
116 \fBGLD_MULTI_DISABLE\fR.
120 .ne 2
122 \fB\fIpromiscflag\fR \fR
124 .RS 18n
125 A flag indicating what type of promiscuous mode, if any, is to be enabled. This
126 argument is specified as \fBGLD_MAC_PROMISC_PHYS\fR,
127 \fBGLD_MAC_PROMISC_MULTI\fR, or \fBGLD_MAC_PROMISC_NONE\fR.
131 .ne 2
133 \fB\fImp\fR \fR
135 .RS 18n
136 Pointer to a STREAMS message block containing the packet to be transmitted or
137 the ioctl to be executed.
141 .ne 2
143 \fB\fIstats\fR \fR
145 .RS 18n
146 Pointer to a \fBgld_stats\fR(9S) structure to be filled in with the current
147 values of statistics counters.
151 .ne 2
153 \fB\fIq\fR \fR
155 .RS 18n
156 Pointer to the \fBqueue\fR(9S) structure to be used in the reply to the ioctl.
159 .SH DESCRIPTION
162 These entry points must be implemented by a device-specific network driver
163 designed to interface with the Generic LAN Driver (GLD).
166 As described in \fBgld\fR(7D), the main data structure for communication
167 between the device-specific driver and the GLD module is the
168 \fBgld_mac_info\fR(9S) structure. Some of the elements in that structure are
169 function pointers to the entry points described here. The device-specific
170 driver must, in its \fBattach\fR(9E) routine, initialize these function
171 pointers before calling \fBgld_register\fR(\|).
174 \fBgldm_reset\fR(\|) resets the hardware to its initial state.
177 \fBgldm_start\fR(\|) enables the device to generate interrupts and prepares the
178 driver to call \fBgld_recv\fR(\|) for delivering received data packets to GLD.
181 \fBgldm_stop\fR(\|) disables the device from generating any interrupts and
182 stops the driver from calling \fBgld_recv\fR(\|) for delivering data packets to
183 GLD. GLD depends on the \fBgldm_stop\fR(\|) routine to ensure that the device
184 will no longer interrupt, and it must do so without fail.
187 \fBgldm_set_mac_addr\fR(\|) sets the physical address that the hardware is to
188 use for receiving data. This function should program the device to the passed
189 MAC address \fImacaddr\fR.
192 \fBgldm_set_multicast\fR(\|) enables and disables device-level reception of
193 specific multicast addresses. If the third argument \fImultiflag\fR is set to
194 \fBGLD_MULTI_ENABLE\fR, then the function sets the interface to receive packets
195 with the multicast address pointed to by the second argument; if
196 \fImultiflag\fR is set to \fBGLD_MULTI_DISABLE\fR, the driver is allowed to
197 disable reception of the specified multicast address.
200 This function is called whenever GLD wants to enable or disable reception of a
201 multicast, group, or functional address. GLD makes no assumptions about how the
202 device does multicast support and calls this function to enable or disable a
203 specific multicast address. Some devices may use a hash algorithm and a bitmask
204 to enable collections of multicast addresses; this is allowed, and GLD will
205 filter out any superfluous packets that are not required. If disabling an
206 address could result in disabling more than one address at the device level, it
207 is the responsibility of the device driver to keep whatever information it
208 needs to avoid disabling an address that GLD has enabled but not disabled.
211 \fBgldm_set_multicast\fR(\|) will not be called to enable a particular
212 multicast address that is already enabled, nor to disable an address that is
213 not currently enabled. GLD keeps track of multiple requests for the same
214 multicast address and only calls the driver's entry point when the first
215 request to enable, or the last request to disable a particular multicast
216 address is made.
219 \fBgldm_set_promiscuous\fR(\|) enables and disables promiscuous mode. This
220 function is called whenever GLD wants to enable or disable the reception of all
221 packets on the medium, or all multicast packets on the medium. If the second
222 argument \fIpromiscflag\fR is set to the value of \fBGLD_MAC_PROMISC_PHYS\fR,
223 then the function enables physical-level promiscuous mode, resulting in the
224 reception of all packets on the medium. If \fIpromiscflag\fR is set to
225 \fBGLD_MAC_PROMISC_MULTI\fR, then reception of all multicast packets will be
226 enabled. If \fIpromiscflag\fR is set to \fBGLD_MAC_PROMISC_NONE\fR, then
227 promiscuous mode is disabled.
230 In the case of a request for promiscuous multicast mode, drivers for devices
231 that have no multicast-only promiscuous mode must set the device to physical
232 promiscuous mode to ensure that all multicast packets are received. In this
233 case the routine should return \fBGLD_SUCCESS\fR. The GLD software will filter
234 out any superfluous packets that are not required.
237 For forward compatibility, \fBgldm_set_promiscuous\fR(\|) routines should treat
238 any unrecognized values for \fIpromiscflag\fR as though they were
239 \fBGLD_MAC_PROMISC_PHYS\fR.
242 \fBgldm_send()\fR queues a packet to the device for transmission. This routine
243 is passed a STREAMS message containing the packet to be sent. The message may
244 comprise multiple message blocks, and the send routine must chain through all
245 the message blocks in the message to access the entire packet to be sent. The
246 driver should be prepared to handle and skip over any zero-length message
247 continuation blocks in the chain. The driver should check to ensure that the
248 packet does not exceed the maximum allowable packet size, and must pad the
249 packet, if necessary, to the minimum allowable packet size. If the send routine
250 successfully transmits or queues the packet, it should return
251 \fBGLD_SUCCESS\fR.
254 The send routine should return \fBGLD_NORESOURCES\fR if it cannot immediately
255 accept the packet for transmission; in this case GLD will retry it later. If
256 \fBgldm_send\fR(\|) ever returns \fBGLD_NORESOURCES\fR, the driver must, at a
257 later time when resources have become available, call \fBgld_sched\fR(\|) to
258 inform GLD that it should retry packets that the driver previously failed to
259 queue for transmission. (If the driver's \fBgldm_stop\fR(\|) routine is called,
260 the driver is absolved from this obligation until it later again returns
261 \fBGLD_NORESOURCES\fR from its \fBgldm_send\fR(\|) routine; however, extra
262 calls to \fBgld_sched\fR(\|) will not cause incorrect operation.)
265 If the driver's send routine returns \fBGLD_SUCCESS\fR, then the driver is
266 responsible for freeing the message when the driver and the hardware no longer
267 need it. If the send routine copied the message into the device, or into a
268 private buffer, then the send routine may free the message after the copy is
269 made. If the hardware uses DMA to read the data directly out of the message
270 data blocks, then the driver must not free the message until the hardware has
271 completed reading the data. In this case the driver will probably free the
272 message in the interrupt routine, or in a buffer-reclaim operation at the
273 beginning of a future send operation. If the send routine returns anything
274 other than \fBGLD_SUCCESS\fR, then the driver must not free the message.
277 \fBgldm_intr()\fR is called when the device might have interrupted. Since it is
278 possible to share interrupts with other devices, the driver must check the
279 device status to determine whether it actually caused an interrupt. If the
280 device that the driver controls did not cause the interrupt, then this routine
281 must return \fBDDI_INTR_UNCLAIMED\fR. Otherwise it must service the interrupt
282 and should return \fBDDI_INTR_CLAIMED\fR. If the interrupt was caused by
283 successful receipt of a packet, this routine should put the received packet
284 into a STREAMS message of type \fBM_DATA\fR and pass that message to
285 \fBgld_recv\fR(\|).
288 \fBgld_recv()\fR will pass the inbound packet upstream to the appropriate next
289 layer of the network protocol stack. It is important to correctly set the
290 \fBb_rptr\fR and \fBb_wptr\fR members of the STREAMS message before calling
291 \fBgld_recv\fR(\|).
294 The driver should avoid holding mutex or other locks during the call to
295 \fBgld_recv\fR(\|). In particular, locks that could be taken by a transmit
296 thread may not be held during a call to \fBgld_recv\fR(\|): the interrupt
297 thread that calls \fBgld_recv\fR(\|) may in some cases carry out processing
298 that includes sending an outgoing packet, resulting in a call to the driver's
299 \fBgldm_send\fR(\|) routine. If the \fBgldm_send\fR(\|) routine were to try to
300 acquire a mutex being held by the \fBgldm_intr\fR(\|) routine at the time it
301 calls \fBgld_recv\fR(\|), this could result in a panic due to recursive mutex
302 entry.
305 The interrupt code should increment statistics counters for any errors. This
306 includes failure to allocate a buffer needed for the received data and any
307 hardware-specific errors such as CRC errors or framing errors.
310 \fBgldm_get_stats\fR(\|) gathers statistics from the hardware and/or driver
311 private counters, and updates the \fBgld_stats\fR(9S) structure pointed to by
312 \fIstats\fR. This routine is called by GLD when it gets a request for
313 statistics, and provides the mechanism by which GLD acquires device dependent
314 statistics from the driver before composing its reply to the statistics
315 request. See \fBgld_stats\fR(9S) and \fBgld\fR(7D) for a description of the
316 defined statistics counters.
319 \fBgldm_ioctl\fR(\|) implements any device-specific ioctl commands. This
320 element may be specified as \fINULL\fR if the driver does not implement any
321 ioctl functions. The driver is responsible for converting the message block
322 into an ioctl reply message and calling the \fBqreply\fR(9F) function before
323 returning \fBGLD_SUCCESS\fR. This function should always return
324 \fBGLD_SUCCESS\fR; any errors the driver may wish to report should be returned
325 via the message passed to \fBqreply\fR(9F). If the \fBgldm_ioctl\fR element is
326 specified as \fINULL\fR, GLD will return a message of type \fBM_IOCNAK\fR with
327 an error of \fBEINVAL\fR.
328 .SH RETURN VALUES
331 \fBgldm_intr\fR(\|) must return:
333 .ne 2
335 \fB\fBDDI_INTR_CLAIMED\fR \fR
337 .RS 23n
338 if and only if the device definitely interrupted.
342 .ne 2
344 \fB\fBDDI_INTR_UNCLAIMED\fR \fR
346 .RS 23n
347 if the device did not interrupt.
352 The other functions must return:
354 .ne 2
356 \fB\fBGLD_SUCCESS\fR \fR
358 .RS 21n
359 on success. \fBgldm_stop\fR(\|) and \fBgldm_ioctl\fR(\|) should always return
360 this value.
364 .ne 2
366 \fB\fBGLD_NORESOURCES\fR \fR
368 .RS 21n
369 if there are insufficient resources to carry out the request at this time. Only
370 \fBgldm_set_mac_addr\fR(\|), \fBgldm_set_multicast\fR(\|),
371 \fBgldm_set_promiscuous\fR(\|), and \fBgldm_send\fR(\|) may return this value.
375 .ne 2
377 \fB\fBGLD_NOLINK\fR \fR
379 .RS 21n
380 if \fBgldm_send\fR(\|) is called when there is no physical connection to a
381 network or link partner.
385 .ne 2
387 \fB\fBGLD_NOTSUPPORTED\fR \fR
389 .RS 21n
390 if the requested function is not supported. Only \fBgldm_set_mac_addr\fR(\|),
391 \fBgldm_set_multicast\fR(\|), and \fBgldm_set_promiscuous\fR(\|) may return
392 this value.
396 .ne 2
398 \fB\fBGLD_BADARG\fR \fR
400 .RS 21n
401 if the function detected an unsuitable argument, for example, a bad multicast
402 address, a bad MAC address, or a bad packet or packet length.
406 .ne 2
408 \fB\fBGLD_FAILURE\fR \fR
410 .RS 21n
411 on hardware failure.
414 .SH SEE ALSO
417 \fBgld\fR(7D), \fBgld\fR(9F), \fBgld_mac_info\fR(9S), \fBgld_stats\fR(9S),
418 \fBdlpi\fR(7P), \fBattach\fR(9E), \fBddi_add_intr\fR(9F)
421 \fIWriting Device Drivers\fR