12c0ebdeeSRobert Mustacchi.\" 22c0ebdeeSRobert Mustacchi.\" This file and its contents are supplied under the terms of the 32c0ebdeeSRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 42c0ebdeeSRobert Mustacchi.\" You may only use this file in accordance with the terms of version 52c0ebdeeSRobert Mustacchi.\" 1.0 of the CDDL. 62c0ebdeeSRobert Mustacchi.\" 72c0ebdeeSRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 82c0ebdeeSRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 92c0ebdeeSRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 102c0ebdeeSRobert Mustacchi.\" 112c0ebdeeSRobert Mustacchi.\" 122c0ebdeeSRobert Mustacchi.\" Copyright (c) 2017, Joyent, Inc. 132c0ebdeeSRobert Mustacchi.\" Copyright 2022 Oxide Computer Company 14*496cffd8SPeter Tribble.\" Copyright 2023 Peter Tribble 152c0ebdeeSRobert Mustacchi.\" 16*496cffd8SPeter Tribble.Dd July 17, 2023 172c0ebdeeSRobert Mustacchi.Dt MAC_CAPAB_RINGS 9E 182c0ebdeeSRobert Mustacchi.Os 192c0ebdeeSRobert Mustacchi.Sh NAME 202c0ebdeeSRobert Mustacchi.Nm mac_capab_rings 212c0ebdeeSRobert Mustacchi.Nd MAC ring capability 222c0ebdeeSRobert Mustacchi.Sh SYNOPSIS 232c0ebdeeSRobert Mustacchi.In sys/mac_provider.h 242c0ebdeeSRobert Mustacchi.Vt typedef struct mac_capab_rings_s mac_capab_rings_t; 252c0ebdeeSRobert Mustacchi.Sh INTERFACE LEVEL 262c0ebdeeSRobert Mustacchi.Sy Uncommitted - 272c0ebdeeSRobert MustacchiThis interface is still evolving. 282c0ebdeeSRobert MustacchiAPI and ABI stability is not guaranteed. 292c0ebdeeSRobert Mustacchi.Sh DESCRIPTION 302c0ebdeeSRobert MustacchiThe 312c0ebdeeSRobert Mustacchi.Sy MAC_CAPAB_RINGS 322c0ebdeeSRobert Mustacchicapability provides a means for device drivers to take advantage of 332c0ebdeeSRobert Mustacchithe additional resources offered by hardware beyond the basic operations 342c0ebdeeSRobert Mustacchito transmit and receive. 352c0ebdeeSRobert MustacchiThere are two primary concepts that this MAC capability relies on: rings 362c0ebdeeSRobert Mustacchiand groups. 372c0ebdeeSRobert Mustacchi.Pp 382c0ebdeeSRobert MustacchiThe 392c0ebdeeSRobert Mustacchi.Em ring 402c0ebdeeSRobert Mustacchiis a abstract concept which must be mapped to some hardware construct by 412c0ebdeeSRobert Mustacchithe driver. 422c0ebdeeSRobert MustacchiIt typically takes the form of a DMA memory region which is divided 432c0ebdeeSRobert Mustacchiinto many smaller units, called descriptors or entries. 442c0ebdeeSRobert MustacchiEach entry in the ring describes a location in memory of a packet, which the 452c0ebdeeSRobert Mustacchihardware is to read from 462c0ebdeeSRobert Mustacchi.Pq to transmit it 472c0ebdeeSRobert Mustacchior write to 482c0ebdeeSRobert Mustacchi.Pq upon reception . 492c0ebdeeSRobert MustacchiEntries also typically contain metadata and attributes about the packet. 502c0ebdeeSRobert MustacchiThese entries are typically arranged in a fixed-size circular buffer 512c0ebdeeSRobert Mustacchi.Po hence the 522c0ebdeeSRobert Mustacchi.Dq ring 532c0ebdeeSRobert Mustacchiname 542c0ebdeeSRobert Mustacchi.Pc 552c0ebdeeSRobert Mustacchiwhich is shared between the operating system and the 562c0ebdeeSRobert Mustacchihardware via the DMA-backed memory. 572c0ebdeeSRobert MustacchiMost NICs, regardless of their support for this capability, use something 582c0ebdeeSRobert Mustacchiresembling a descriptor ring under the hood. 592c0ebdeeSRobert MustacchiSome vendors may also refer to rings as 602c0ebdeeSRobert Mustacchi.Em queues . 612c0ebdeeSRobert MustacchiThe ring concept is intentionally general, so that more unusual underlying 622c0ebdeeSRobert Mustacchihardware constructs can also be used to implement it. 632c0ebdeeSRobert Mustacchi.Pp 642c0ebdeeSRobert MustacchiA collection of one or more rings is called a 652c0ebdeeSRobert Mustacchi.Em group . 662c0ebdeeSRobert MustacchiEach group usually has a collection of filters that can be associated 672c0ebdeeSRobert Mustacchiwith them. 682c0ebdeeSRobert MustacchiThese filters are usually defined in terms of matching something like a 692c0ebdeeSRobert MustacchiMAC address, VLAN, or Ethertype, though more complex filters may exist 702c0ebdeeSRobert Mustacchiin hardware. 712c0ebdeeSRobert MustacchiWhen a packet matches a filter, it will then be directed to the group 722c0ebdeeSRobert Mustacchiand eventually delivered to one of the rings in the group. 732c0ebdeeSRobert Mustacchi.Pp 742c0ebdeeSRobert MustacchiIn the MAC framework, rings and groups are separated into categories 752c0ebdeeSRobert Mustacchibased on their purpose: transmitting and receiving. 762c0ebdeeSRobert MustacchiWhile the MAC framework thinks of transmit and receive rings as 772c0ebdeeSRobert Mustacchidifferent physical constructs, they may map to the same underlying 782c0ebdeeSRobert Mustacchiresources in the hardware. 792c0ebdeeSRobert MustacchiThe device driver may implement the 802c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 812c0ebdeeSRobert Mustacchicapability for one of transmitting, receiving, or both. 822c0ebdeeSRobert Mustacchi.Ss Mapping Hardware to Rings and Groups 832c0ebdeeSRobert MustacchiThere are many different ways that hardware resources may map to this 842c0ebdeeSRobert Mustacchicapability. 852c0ebdeeSRobert MustacchiConsider the following examples: 862c0ebdeeSRobert Mustacchi.Bl -enum 872c0ebdeeSRobert Mustacchi.It 882c0ebdeeSRobert MustacchiHardware may support a feature commonly known as receive side scaling 892c0ebdeeSRobert Mustacchi.Pq RSS . 902c0ebdeeSRobert MustacchiWith RSS, the hardware has multiple rings and uses a hash function 912c0ebdeeSRobert Mustacchicalculated over packet headers to choose which ring receives a 922c0ebdeeSRobert Mustacchiparticular packet. 932c0ebdeeSRobert MustacchiRings are associated with different interrupts, allowing multiple rings 942c0ebdeeSRobert Mustacchito be processed in parallel. 952c0ebdeeSRobert MustacchiSupporting RSS in isolation would result in a device which has a single 962c0ebdeeSRobert Mustacchigroup, and multiple rings within that group. 972c0ebdeeSRobert Mustacchi.It 982c0ebdeeSRobert MustacchiSome hardware may have a single ring, but still support multiple receive 992c0ebdeeSRobert Mustacchifilters. 1002c0ebdeeSRobert MustacchiThis is commonly seen with some 1 GbE devices. 1012c0ebdeeSRobert MustacchiWhile the hardware only has one ring, it has support for multiple 1022c0ebdeeSRobert Mustacchiindependent MAC address filters, each of which can be programmed to 1032c0ebdeeSRobert Mustacchireceive traffic for a single MAC address. 1042c0ebdeeSRobert MustacchiThe driver should map this situation to a single group with a single 1052c0ebdeeSRobert Mustacchiring. 1062c0ebdeeSRobert MustacchiHowever, it would implement the ability to program several filters. 1072c0ebdeeSRobert MustacchiWhile this may not seem useful at first, when virtual NICs are created 1082c0ebdeeSRobert Mustacchion top of a physical NIC, the additional hardware filters will be used 1092c0ebdeeSRobert Mustacchito avoid putting the device in promiscuous mode. 1102c0ebdeeSRobert Mustacchi.It 1112c0ebdeeSRobert MustacchiFinally, some hardware has many rings, which can be placed in many 1122c0ebdeeSRobert Mustacchidifferent groups. 1132c0ebdeeSRobert MustacchiEach group has its own filtering capabilities. 1142c0ebdeeSRobert MustacchiFor such hardware, the device driver would declare support for multiple 1152c0ebdeeSRobert Mustacchigroups, each of which has its own independent set of rings. 1162c0ebdeeSRobert Mustacchi.El 1172c0ebdeeSRobert Mustacchi.Pp 1182c0ebdeeSRobert MustacchiWhen choosing hardware constructs to implement rings and groups, it is 1192c0ebdeeSRobert Mustacchialso important to consider interrupts. 1202c0ebdeeSRobert MustacchiIn order to support polling, each receive ring must be able to 1212c0ebdeeSRobert Mustacchiindependently toggle whether that ring will generate an interrupt on 1222c0ebdeeSRobert Mustacchipacket reception, even when many rings share the same hardware level 1232c0ebdeeSRobert Mustacchiinterrupt 1242c0ebdeeSRobert Mustacchi.Pq e.g. the same MSI or MSI-X interrupt number and handler . 1252c0ebdeeSRobert Mustacchi.Ss Filters 1262c0ebdeeSRobert MustacchiThe 1272c0ebdeeSRobert Mustacchi.Xr mac_group_info 9S 1282c0ebdeeSRobert Mustacchistructure is used to define several different kinds of filters that the 1292c0ebdeeSRobert Mustacchigroup might implement. 1302c0ebdeeSRobert MustacchiThere are three different classes of filters that exist: 1312c0ebdeeSRobert Mustacchi.Bl -tag -width Ds 1322c0ebdeeSRobert Mustacchi.It Sy MAC Address 1332c0ebdeeSRobert MustacchiA given frame matches a MAC Address filter if the receive address in 1342c0ebdeeSRobert Mustacchithe Ethernet Header matches the specified MAC address. 1352c0ebdeeSRobert Mustacchi.It Sy VLAN 1362c0ebdeeSRobert MustacchiA given frame matches a VLAN filter if it both has an 802.1Q VLAN tag 1372c0ebdeeSRobert Mustacchiand that tag matches the VALN number specified in the filter. 1382c0ebdeeSRobert MustacchiIf the frame's outer ethertype is not 0x8100, then the filter will not 1392c0ebdeeSRobert Mustacchimatch. 1402c0ebdeeSRobert Mustacchi.It Sy MAC Address and VLAN 1412c0ebdeeSRobert MustacchiA given frame matches a MAC Address and VLAN filter if it matches both 1422c0ebdeeSRobert Mustacchithe specified MAC address and the specified VLAN. 1432c0ebdeeSRobert MustacchiThis is constructed as a logical AND of the previous two filters. 1442c0ebdeeSRobert MustacchiIf only one of the two matches, then the frame does not match this 1452c0ebdeeSRobert Mustacchifilter. 1462c0ebdeeSRobert Mustacchi.Pp 1472c0ebdeeSRobert MustacchiNote: this filter type is still under development and has not been 1482c0ebdeeSRobert Mustacchiplumbed through our APIs yet. 1492c0ebdeeSRobert Mustacchi.El 1502c0ebdeeSRobert Mustacchi.Pp 1512c0ebdeeSRobert MustacchiDevices may support many different filter types. 1522c0ebdeeSRobert MustacchiIf the hardware resources required for a combined filter type 1532c0ebdeeSRobert Mustacchi.Pq e.g. MAC Address and VLAN 1542c0ebdeeSRobert Mustacchiare similar to the resources required for each in isolation, drivers 1552c0ebdeeSRobert Mustacchishould prefer to implement just the combined type and should not 1562c0ebdeeSRobert Mustacchiimplement the individual types. 1572c0ebdeeSRobert Mustacchi.Pp 1582c0ebdeeSRobert MustacchiThe MAC framework assumes that the following rules hold regarding 1592c0ebdeeSRobert Mustacchifilters: 1602c0ebdeeSRobert Mustacchi.Bl -enum 1612c0ebdeeSRobert Mustacchi.It 1622c0ebdeeSRobert MustacchiWhen there are multiple filters of the same kind with different 1632c0ebdeeSRobert Mustacchiaddresses, then the hardware will accept a frame if it matches 1642c0ebdeeSRobert Mustacchi.Em ANY 1652c0ebdeeSRobert Mustacchiof the specified filters. 1662c0ebdeeSRobert MustacchiIn other words, if there are two VLAN filters defined, one for VLAN 23 1672c0ebdeeSRobert Mustacchiand one for VLAN 42, then if a frame has either VLAN 23 or VLAN 42, 1682c0ebdeeSRobert Mustacchiit will be accepted for the group. 1692c0ebdeeSRobert Mustacchi.It 1702c0ebdeeSRobert MustacchiIf multiple different classes of filters are defined, then the hardware 1712c0ebdeeSRobert Mustacchishould only accept a frame if it passes 1722c0ebdeeSRobert Mustacchi.Em ALL 1732c0ebdeeSRobert Mustacchiof the filter classes. 1742c0ebdeeSRobert MustacchiFor example, if there is a MAC address filter and a separate VLAN 1752c0ebdeeSRobert Mustacchifilter, the hardware will only accept the frame if it passes both sets 1762c0ebdeeSRobert Mustacchiof filters. 1772c0ebdeeSRobert Mustacchi.It 1782c0ebdeeSRobert MustacchiIf there are multiple different classes of filters and there are 1792c0ebdeeSRobert Mustacchimultiple filters present in each class, then the driver will accept a 1802c0ebdeeSRobert Mustacchipacket as long as it matches 1812c0ebdeeSRobert Mustacchi.Em ALL 1822c0ebdeeSRobert Mustacchifilter classes. 1832c0ebdeeSRobert MustacchiHowever, within a given filter class, it may match 1842c0ebdeeSRobert Mustacchi.Em ANY 1852c0ebdeeSRobert Mustacchiof the filters. 1862c0ebdeeSRobert MustacchiSee the following boolean logic as an alternative way to phrase this 1872c0ebdeeSRobert Mustacchicase: 1882c0ebdeeSRobert Mustacchi.Bd -literal -offset indent 1892c0ebdeeSRobert Mustacchimatch = MAC && VLAN 1902c0ebdeeSRobert MustacchiMAC = 00:11:22:33:44:55 OR 00:66:77:88:99:aa OR ... 1912c0ebdeeSRobert MustacchiVLAN = 11 OR 12 OR ... 1922c0ebdeeSRobert Mustacchi.Ed 1932c0ebdeeSRobert Mustacchi.El 1942c0ebdeeSRobert Mustacchi.Pp 195*496cffd8SPeter TribbleThe following pseudocode summarizes the behavior for a device that 1962c0ebdeeSRobert Mustacchisupports independent MAC and VLAN filters. 1972c0ebdeeSRobert MustacchiIf the hardware only supports a single family of filters, then simply 198*496cffd8SPeter Tribbletreat that in the pseudocode as though it is always true: 1992c0ebdeeSRobert Mustacchi.Bd -literal -offset indent 2002c0ebdeeSRobert Mustacchifor each packet p: 2012c0ebdeeSRobert Mustacchi for each MAC filter m: 2022c0ebdeeSRobert Mustacchi if m matches p's mac: 2032c0ebdeeSRobert Mustacchi for each VLAN filter v: 2042c0ebdeeSRobert Mustacchi if v matches p's vlan: 2052c0ebdeeSRobert Mustacchi accept p for group 2062c0ebdeeSRobert Mustacchi proceed to next packet 2072c0ebdeeSRobert Mustacchi reject packet p 2082c0ebdeeSRobert Mustacchi proceed to next packet 2092c0ebdeeSRobert Mustacchi.Ed 2102c0ebdeeSRobert Mustacchi.Pp 211*496cffd8SPeter TribbleThe following pseudocode summarizes the behavior for a device that 2122c0ebdeeSRobert Mustacchisupports a combined MAC address and VLAN filter: 2132c0ebdeeSRobert Mustacchi.Bd -literal -offset indent 2142c0ebdeeSRobert Mustacchifor each packet p: 2152c0ebdeeSRobert Mustacchi for each filter f: 2162c0ebdeeSRobert Mustacchi if f.mac matches p's mac and f.vlan matches p's vlan: 2172c0ebdeeSRobert Mustacchi accept p for group 2182c0ebdeeSRobert Mustacchi proceed to next packet 2192c0ebdeeSRobert Mustacchi reject packet p 2202c0ebdeeSRobert Mustacchi proceed to next packet 2212c0ebdeeSRobert Mustacchi.Ed 2222c0ebdeeSRobert Mustacchi.Ss MAC Capability Structure 2232c0ebdeeSRobert MustacchiWhen the device driver's 2242c0ebdeeSRobert Mustacchi.Xr mc_getcapab 9E 2252c0ebdeeSRobert Mustacchifunction entry point is called with the capability requested set to 2262c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS , 2272c0ebdeeSRobert Mustacchithen the value of the capability structure is a pointer to a 2282c0ebdeeSRobert Mustacchi.Vt mac_capab_rings_t 2292c0ebdeeSRobert Mustacchistructure with the following members: 2302c0ebdeeSRobert Mustacchi.Bd -literal -offset indent 2312c0ebdeeSRobert Mustacchimac_ring_type_t mr_type; 232*496cffd8SPeter Tribblemac_group_type_t mr_group_type; 2332c0ebdeeSRobert Mustacchiuint_t mr_rnum; 2342c0ebdeeSRobert Mustacchiuint_t mr_gnum; 2352c0ebdeeSRobert Mustacchimac_get_ring_t mr_rget; 2362c0ebdeeSRobert Mustacchimac_get_group_t mr_gget; 2372c0ebdeeSRobert Mustacchi.Ed 2382c0ebdeeSRobert Mustacchi.Pp 2392c0ebdeeSRobert MustacchiIf the driver supports the 2402c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 2412c0ebdeeSRobert Mustacchicapability, then it should first check the 2422c0ebdeeSRobert Mustacchi.Fa mr_type 2432c0ebdeeSRobert Mustacchimember of the structure. 2442c0ebdeeSRobert MustacchiThis member has the following possible values: 2452c0ebdeeSRobert Mustacchi.Bl -tag -width Dv 2462c0ebdeeSRobert Mustacchi.It Dv MAC_RING_TYPE_RX 2472c0ebdeeSRobert MustacchiIndicates that this group is for receive rings. 2482c0ebdeeSRobert Mustacchi.It Dv MAC_RING_TYPE_TX 2492c0ebdeeSRobert MustacchiIndicates that this group is for transmit rings. 2502c0ebdeeSRobert Mustacchi.El 2512c0ebdeeSRobert Mustacchi.Pp 2522c0ebdeeSRobert MustacchiThe driver will be asked to fill in this capability structure separately 2532c0ebdeeSRobert Mustacchifor receive and transmit groups and rings. 2542c0ebdeeSRobert MustacchiThis allows a driver to have different entry points for each type. 2552c0ebdeeSRobert MustacchiIf neither of these values is specified, then the device driver must 2562c0ebdeeSRobert Mustacchireturn 2572c0ebdeeSRobert Mustacchi.Dv B_FALSE 2582c0ebdeeSRobert Mustacchifrom its 2592c0ebdeeSRobert Mustacchi.Xr mc_getcapab 9E 2602c0ebdeeSRobert Mustacchientry point. 2612c0ebdeeSRobert MustacchiOnce it has identified the type, it should fill in the capability 2622c0ebdeeSRobert Mustacchistructure based on the following rules: 2632c0ebdeeSRobert Mustacchi.Bl -tag -width Fa 2642c0ebdeeSRobert Mustacchi.It Fa mr_type 2652c0ebdeeSRobert MustacchiThe 2662c0ebdeeSRobert Mustacchi.Fa mr_type 2672c0ebdeeSRobert Mustacchimember is used to indicate whether this group is for transmit or receive 2682c0ebdeeSRobert Mustacchirings. 2692c0ebdeeSRobert MustacchiThe 2702c0ebdeeSRobert Mustacchi.Fa mr_type 2712c0ebdeeSRobert Mustacchimember should not be modified by the device driver. 2722c0ebdeeSRobert MustacchiIt is set by the MAC framework when the driver's 2732c0ebdeeSRobert Mustacchi.Xr mc_getcapab 9E 2742c0ebdeeSRobert Mustacchientry point is called. 2752c0ebdeeSRobert MustacchiAs indicated above, the driver must check the value to determine which 2762c0ebdeeSRobert Mustacchigroup this 2772c0ebdeeSRobert Mustacchi.Xr mc_getcapab 9E 2782c0ebdeeSRobert Mustacchicall is referring to. 2792c0ebdeeSRobert Mustacchi.It Fa mr_group_type 2802c0ebdeeSRobert MustacchiThis member is used to indicate the group type. 2812c0ebdeeSRobert MustacchiThis should be set to 2822c0ebdeeSRobert Mustacchi.Dv MAC_GROUP_TYPE_STATIC , 2832c0ebdeeSRobert Mustacchiwhich indicates that the assignment of rings to groups is fixed, and 2842c0ebdeeSRobert Mustacchieach ring can only ever belong to one specific group. 2852c0ebdeeSRobert MustacchiThe number of rings per group may vary on the group and can be set by 2862c0ebdeeSRobert Mustacchithe driver. 2872c0ebdeeSRobert Mustacchi.It Fa mr_rnum 2882c0ebdeeSRobert MustacchiThis indicates the total number of rings that are available. 2892c0ebdeeSRobert MustacchiThe number exposed may be less than the number supported in hardware. 2902c0ebdeeSRobert MustacchiThis is often due to receiving fewer resources such as interrupts. 2912c0ebdeeSRobert Mustacchi.It Fa mr_gnum 2922c0ebdeeSRobert MustacchiThis indicates the total number of groups that are available from 2932c0ebdeeSRobert Mustacchihardware. 2942c0ebdeeSRobert MustacchiThe number exposed may be less than the number supported in hardware. 2952c0ebdeeSRobert MustacchiThis is often due to receiving fewer resources such as interrupts. 2962c0ebdeeSRobert Mustacchi.Pp 2972c0ebdeeSRobert MustacchiWhen working with transmit rings, this value may be zero. 2982c0ebdeeSRobert MustacchiIn this case, each ring is treated independently and separate groups for 2992c0ebdeeSRobert Mustacchieach transmit ring are not required. 3002c0ebdeeSRobert Mustacchi.It Fa mr_rget 3012c0ebdeeSRobert MustacchiThis member is a function pointer that will be called to provide 3022c0ebdeeSRobert Mustacchiinformation about a ring inside of a specific group. 3032c0ebdeeSRobert MustacchiSee 3042c0ebdeeSRobert Mustacchi.Xr mr_rget 9E 3052c0ebdeeSRobert Mustacchifor information on the function, its signature, and responsibilities. 3062c0ebdeeSRobert Mustacchi.It Fa mr_gget 3072c0ebdeeSRobert MustacchiThis member is a function pointer that will be called to provide 3082c0ebdeeSRobert Mustacchiinformation about a group. 3092c0ebdeeSRobert MustacchiSee 3102c0ebdeeSRobert Mustacchi.Xr mr_gget 9E 3112c0ebdeeSRobert Mustacchifor information on the function, its signature, and responsibilities. 3122c0ebdeeSRobert Mustacchi.El 3132c0ebdeeSRobert Mustacchi.Sh DRIVER IMPLICATIONS 3142c0ebdeeSRobert Mustacchi.Ss MAC Callback Entry Points 3152c0ebdeeSRobert MustacchiWhen a driver implements the 3162c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 3172c0ebdeeSRobert Mustacchicapability, then it must not implement some of the traditional MAC 3182c0ebdeeSRobert Mustacchicallbacks. 3192c0ebdeeSRobert MustacchiIf the driver supports 3202c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 3212c0ebdeeSRobert Mustacchifor receiving, then it must not implement the 3222c0ebdeeSRobert Mustacchi.Xr mc_unicst 9E 3232c0ebdeeSRobert Mustacchientry point. 3242c0ebdeeSRobert MustacchiThis is instead handled through the filters that were described earlier. 3252c0ebdeeSRobert MustacchiThe filter entry points are defined as part of the 3262c0ebdeeSRobert Mustacchi.Xr mac_group_info 9S 3272c0ebdeeSRobert Mustacchistructure. 3282c0ebdeeSRobert Mustacchi.Pp 3292c0ebdeeSRobert MustacchiIf the driver supports 3302c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 3312c0ebdeeSRobert Mustacchifor transmitting, then it should not implement the 3322c0ebdeeSRobert Mustacchi.Xr mc_tx 9E 3332c0ebdeeSRobert Mustacchientry point, it will not be used. 3342c0ebdeeSRobert MustacchiThe MAC framework will instead use the 3352c0ebdeeSRobert Mustacchi.Xr mri_tx 9E 3362c0ebdeeSRobert Mustacchientry point that is provided by the driver in the 3372c0ebdeeSRobert Mustacchi.Xr mac_ring_info 9S 3382c0ebdeeSRobert Mustacchistructure. 3392c0ebdeeSRobert Mustacchi.Ss Locking and Concurrency 3402c0ebdeeSRobert MustacchiOne of the main points of the 3412c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 3422c0ebdeeSRobert Mustacchicapability is to increase the parallelism and concurrency that is 3432c0ebdeeSRobert Mustacchiactively going on in the driver. 344*496cffd8SPeter TribbleThis means that a driver may be asked to transmit, poll, or receive 3452c0ebdeeSRobert Mustacchiinterrupts on all of its rings in parallel. 3462c0ebdeeSRobert MustacchiThis usually calls for fine-grained locking in a driver's own data 3472c0ebdeeSRobert Mustacchistructures to ensure that the various rings can be populated and used 3482c0ebdeeSRobert Mustacchiwithout having to block on one another. 3492c0ebdeeSRobert MustacchiIn general, most drivers have their own independent set of locks for 3502c0ebdeeSRobert Mustacchieach transmit and receive ring. 3512c0ebdeeSRobert MustacchiThey also usually have separate locks for each group. 3522c0ebdeeSRobert Mustacchi.Pp 3532c0ebdeeSRobert MustacchiJust because one driver performs locking in one way, does not mean that 3542c0ebdeeSRobert Mustacchione has to mimic it. 3552c0ebdeeSRobert MustacchiThe design of a driver and its locking is often tightly coupled to how 3562c0ebdeeSRobert Mustacchithe underlying hardware works and its complexity. 3572c0ebdeeSRobert Mustacchi.Ss Polling on rings 3582c0ebdeeSRobert MustacchiWhen the 3592c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 3602c0ebdeeSRobert Mustacchicapability is implemented, then additional functionality for receiving 3612c0ebdeeSRobert Mustacchibecomes available. 3622c0ebdeeSRobert MustacchiA receive ring has the ability to be polled. 3632c0ebdeeSRobert MustacchiWhen the operating system desires to begin polling the ring, it will 3642c0ebdeeSRobert Mustacchimake a function call into the driver, asking it to receive packets from 3652c0ebdeeSRobert Mustacchithis ring. 3662c0ebdeeSRobert MustacchiWhen receiving packets while polling, the process is generally identical 3672c0ebdeeSRobert Mustacchito that described in the 3682c0ebdeeSRobert Mustacchi.Sy Receiving Data 3692c0ebdeeSRobert Mustacchisection of 3702c0ebdeeSRobert Mustacchi.Xr mac 9E . 3712c0ebdeeSRobert MustacchiFor more details, see 3722c0ebdeeSRobert Mustacchi.Xr mri_poll 9E . 3732c0ebdeeSRobert Mustacchi.Pp 3742c0ebdeeSRobert MustacchiWhen the MAC framework wants to enable polling, it will first turn off 3752c0ebdeeSRobert Mustacchiinterrupts through the 3762c0ebdeeSRobert Mustacchi.Xr mi_disable 9E 3772c0ebdeeSRobert Mustacchientry point on the driver. 3782c0ebdeeSRobert MustacchiThe driver must ensure that there is proper serialization between the 3792c0ebdeeSRobert Mustacchiinterrupt enablement, interrupt disablement, the interrupt handler for 3802c0ebdeeSRobert Mustacchithat ring, and the 3812c0ebdeeSRobert Mustacchi.Xr mri_poll 9E 3822c0ebdeeSRobert Mustacchientry point. 3832c0ebdeeSRobert MustacchiFor more information on the locking requirements related to polling, see 3842c0ebdeeSRobert Mustacchithe discussions in 3852c0ebdeeSRobert Mustacchi.Xr mri_poll 9E 3862c0ebdeeSRobert Mustacchiand 3872c0ebdeeSRobert Mustacchi.Xr mi_disable 9E . 3882c0ebdeeSRobert Mustacchi.Ss Updated callback functions 3892c0ebdeeSRobert MustacchiWhen using rings, two of the primary functions that were used change. 3902c0ebdeeSRobert MustacchiFirst, the 3912c0ebdeeSRobert Mustacchi.Xr mac_rx 9F 3922c0ebdeeSRobert Mustacchifunction should be replaced with the 393*496cffd8SPeter Tribble.Xr mac_rx_ring 9F 3942c0ebdeeSRobert Mustacchifunction. 3952c0ebdeeSRobert MustacchiSecondly, 3962c0ebdeeSRobert Mustacchithe 3972c0ebdeeSRobert Mustacchi.Xr mac_tx_update 9F 3982c0ebdeeSRobert Mustacchifunction should be replaced with the 3992c0ebdeeSRobert Mustacchi.Xr mac_tx_ring_update 9F 4002c0ebdeeSRobert Mustacchifunction. 4012c0ebdeeSRobert Mustacchi.Ss Interrupt and Ring Mapping 4022c0ebdeeSRobert MustacchiDrivers often vary the number of rings that they expose based on the 4032c0ebdeeSRobert Mustacchinumber of interrupts that exist. 4042c0ebdeeSRobert MustacchiWhen a driver only supports a single group, there is often no reason to 4052c0ebdeeSRobert Mustacchihave more rings than interrupts. 4062c0ebdeeSRobert MustacchiHowever, most hardware supports a means of having multiple rings tie to 4072c0ebdeeSRobert Mustacchithe same interrupt. 4082c0ebdeeSRobert MustacchiDrivers then tie the rings in different groups to the same interrupts 4092c0ebdeeSRobert Mustacchiand therefore when an interrupt is triggered, iterate over all of the 4102c0ebdeeSRobert Mustacchirings. 4112c0ebdeeSRobert Mustacchi.Pp 4122c0ebdeeSRobert MustacchiTying multiple rings together into a single interrupt should only be done 4132c0ebdeeSRobert Mustacchiif hardware has the ability to control whether or not each ring 4142c0ebdeeSRobert Mustacchicontributes to the interrupt. 4152c0ebdeeSRobert MustacchiFor the 4162c0ebdeeSRobert Mustacchi.Xr mi_disable 9E 4172c0ebdeeSRobert Mustacchientry point to work, each ring must be able to independently control 4182c0ebdeeSRobert Mustacchiwhether or not receipt of a packet generates the shared interrupt. 4192c0ebdeeSRobert Mustacchi.Ss Filter Management 4202c0ebdeeSRobert MustacchiAs part of general operation, the device driver will be asked to add 4212c0ebdeeSRobert Mustacchivarious filters to groups. 4222c0ebdeeSRobert MustacchiThe MAC framework does not keep track of the assigned filters in such a 4232c0ebdeeSRobert Mustacchiway that after a device reset that they'll be given to the driver again. 4242c0ebdeeSRobert MustacchiTherefore, it is recommended that the driver keep track of all filters 4252c0ebdeeSRobert Mustacchiit has assigned such that they can be reinstated after a driver or 4262c0ebdeeSRobert Mustacchisystem initiated device reset of some kind. 4272c0ebdeeSRobert MustacchiThere is no need to persist anything across a call to 4282c0ebdeeSRobert Mustacchi.Xr detach 9E 4292c0ebdeeSRobert Mustacchior similar. 4302c0ebdeeSRobert Mustacchi.Pp 4312c0ebdeeSRobert MustacchiFor more information, see the 4322c0ebdeeSRobert Mustacchi.Sy TX STALL DETECTION, DEVICE RESETS, AND FAULT MANAGEMENT 4332c0ebdeeSRobert Mustacchisection of 4342c0ebdeeSRobert Mustacchi.Xr mac 9E . 4352c0ebdeeSRobert Mustacchi.Ss Broadcast, Multicast, and Promiscuous Mode 4362c0ebdeeSRobert MustacchiRings and groups are currently designed to emphasize and enhance the 4372c0ebdeeSRobert Mustacchireceipt of filtered, unicast frames. 4382c0ebdeeSRobert MustacchiThis means that special handling is required when working with broadcast 4392c0ebdeeSRobert Mustacchitraffic, multicast traffic, and enabling promiscuous mode. 4402c0ebdeeSRobert MustacchiThis only applies to receive groups and rings. 4412c0ebdeeSRobert Mustacchi.Pp 4422c0ebdeeSRobert MustacchiBy default, only the first group with index zero, sometimes called the 4432c0ebdeeSRobert Mustacchidefault group, should ever be 4442c0ebdeeSRobert Mustacchiprogrammed to receive broadcast traffic. 4452c0ebdeeSRobert MustacchiThis group should always be programmed to receive broadcast traffic, the 4462c0ebdeeSRobert Mustacchisame way that the broader device is programmed to always receive 4472c0ebdeeSRobert Mustacchibroadcast traffic when the 4482c0ebdeeSRobert Mustacchi.Dv MAC_CAPAB_RINGS 4492c0ebdeeSRobert Mustacchicapability has not been negotiated. 4502c0ebdeeSRobert Mustacchi.Pp 4512c0ebdeeSRobert MustacchiWhen multicast addresses are assigned to the device through the 4522c0ebdeeSRobert Mustacchi.Xr mc_multicst 9E 4532c0ebdeeSRobert Mustacchientry point, those should also be assigned to the first group. 4542c0ebdeeSRobert Mustacchi.Pp 4552c0ebdeeSRobert MustacchiSimilarly, when enabling promiscuous mode, the driver should only enable 4562c0ebdeeSRobert Mustacchipromiscuous traffic to be received by the first group. 4572c0ebdeeSRobert Mustacchi.Pp 4582c0ebdeeSRobert MustacchiNo other groups or rings should ever receive broadcast, multicast, or 4592c0ebdeeSRobert Mustacchipromiscuous mode traffic. 4602c0ebdeeSRobert Mustacchi.Sh SEE ALSO 4612c0ebdeeSRobert Mustacchi.Xr mac 9E , 4622c0ebdeeSRobert Mustacchi.Xr mc_getcapab 9E , 4632c0ebdeeSRobert Mustacchi.Xr mc_multicst 9E , 4642c0ebdeeSRobert Mustacchi.Xr mc_tx 9E , 4652c0ebdeeSRobert Mustacchi.Xr mc_unicst 9E , 4662c0ebdeeSRobert Mustacchi.Xr mi_disable 9E , 4672c0ebdeeSRobert Mustacchi.Xr mr_gaddring 9E , 4682c0ebdeeSRobert Mustacchi.Xr mr_gget 9E , 4692c0ebdeeSRobert Mustacchi.Xr mr_gremring 9E , 4702c0ebdeeSRobert Mustacchi.Xr mr_rget 9E , 4712c0ebdeeSRobert Mustacchi.Xr mri_poll 9E , 4722c0ebdeeSRobert Mustacchi.Xr mac_rx 9F , 473*496cffd8SPeter Tribble.Xr mac_rx_ring 9F , 4742c0ebdeeSRobert Mustacchi.Xr mac_tx_ring_update 9F , 4752c0ebdeeSRobert Mustacchi.Xr mac_tx_update 9F , 4762c0ebdeeSRobert Mustacchi.Xr mac_group_info 9S 477