152d2369aSRobert Mustacchi.\" 252d2369aSRobert Mustacchi.\" This file and its contents are supplied under the terms of the 352d2369aSRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 452d2369aSRobert Mustacchi.\" You may only use this file in accordance with the terms of version 552d2369aSRobert Mustacchi.\" 1.0 of the CDDL. 652d2369aSRobert Mustacchi.\" 752d2369aSRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 852d2369aSRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 952d2369aSRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 1052d2369aSRobert Mustacchi.\" 1152d2369aSRobert Mustacchi.\" 12*ec71f88eSPatrick Mooney.\" Copyright 2018 Joyent, Inc. 1352d2369aSRobert Mustacchi.\" 14*ec71f88eSPatrick Mooney.Dd March 15, 2018 1552d2369aSRobert Mustacchi.Dt MAC_HCKSUM_GET 9F 1652d2369aSRobert Mustacchi.Os 1752d2369aSRobert Mustacchi.Sh NAME 1852d2369aSRobert Mustacchi.Nm mac_hcksum_get , 1952d2369aSRobert Mustacchi.Nm mac_hcksum_set 2052d2369aSRobert Mustacchi.Nd get and set checksum information on message blocks 2152d2369aSRobert Mustacchi.Sh SYNOPSIS 2252d2369aSRobert Mustacchi.In sys/mac_provider.h 2352d2369aSRobert Mustacchi.Ft void 2452d2369aSRobert Mustacchi.Fo mac_hcksum_get 25*ec71f88eSPatrick Mooney.Fa "const mblk_t *mp" 2652d2369aSRobert Mustacchi.Fa "uint32_t *start" 2752d2369aSRobert Mustacchi.Fa "uint32_t *stuff" 2852d2369aSRobert Mustacchi.Fa "uint32_t *end" 2952d2369aSRobert Mustacchi.Fa "uint32_t *value" 3052d2369aSRobert Mustacchi.Fa "uint32_t *flags" 3152d2369aSRobert Mustacchi.Fc 3252d2369aSRobert Mustacchi.Ft void 3352d2369aSRobert Mustacchi.Fo mac_hcksum_set 3452d2369aSRobert Mustacchi.Fa "mblk_t *mp" 3552d2369aSRobert Mustacchi.Fa "uint32_t start" 3652d2369aSRobert Mustacchi.Fa "uint32_t stuff" 3752d2369aSRobert Mustacchi.Fa "uint32_t end" 3852d2369aSRobert Mustacchi.Fa "uint32_t value" 3952d2369aSRobert Mustacchi.Fa "uint32_t flags" 4052d2369aSRobert Mustacchi.Fc 4152d2369aSRobert Mustacchi.Sh INTERFACE LEVEL 4252d2369aSRobert Mustacchiillumos DDI specific 4352d2369aSRobert Mustacchi.Sh PARAMETERS 4452d2369aSRobert Mustacchi.Bl -tag -width Fa 4552d2369aSRobert Mustacchi.It Fa mp 4652d2369aSRobert MustacchiA pointer to a 4752d2369aSRobert Mustacchi.Xr mblk 9S 4852d2369aSRobert Mustacchistructure that contains a frame. 4952d2369aSRobert Mustacchi.It Fa start 5052d2369aSRobert MustacchiThe value or a pointer to it that contains the offset from the L3 5152d2369aSRobert Mustacchiheader, generally IP, of the first byte that's covered by the checksum. 5252d2369aSRobert Mustacchi.It Fa stuff 5352d2369aSRobert MustacchiThe value or a pointer to it that contains the offset from the L3 header 5472d3dbb9SYuri Pankovof where the L4 checksum is. 5572d3dbb9SYuri PankovFor example, if using IPv4 and TCP, this would contain the offset from the start 5672d3dbb9SYuri Pankovof the IPv4 header to the first byte of the TCP checksum. 5752d2369aSRobert Mustacchi.It Fa end 5852d2369aSRobert MustacchiThe value or a pointer to it that contains the offset from the L3 5952d2369aSRobert Mustacchiheader, generally IP, of the last byte that's covered by the checksum. 6052d2369aSRobert Mustacchi.It Fa value 6152d2369aSRobert MustacchiThe value or a pointer to it that contains the actual value of the 6252d2369aSRobert Mustacchichecksum. 6352d2369aSRobert Mustacchi.It Fa flags 6452d2369aSRobert MustacchiA series of one or more flags that have bitwise inclusive ORed together. 6552d2369aSRobert MustacchiThe set of flags have different meanings depending on whether 6652d2369aSRobert Mustacchi.Fa mp 6752d2369aSRobert Mustacchiis being transmitted or received. 6852d2369aSRobert Mustacchi.El 6952d2369aSRobert Mustacchi.Sh DESCRIPTION 7052d2369aSRobert MustacchiThe 7152d2369aSRobert Mustacchi.Fn mac_hcksum_get 7252d2369aSRobert Mustacchiand 7352d2369aSRobert Mustacchi.Fn mac_hcksum_set 7452d2369aSRobert Mustacchifunctions are provided to device drivers to get and set checksum related 7572d3dbb9SYuri Pankovinformation. 7672d3dbb9SYuri PankovWhen a device driver indicates that it supports the 7752d2369aSRobert Mustacchi.Sy MAC_CAPAB_HCKSUM 7852d2369aSRobert Mustacchicapability as part of its 7952d2369aSRobert Mustacchi.Xr mc_getcapab 9E 8052d2369aSRobert Mustacchientry point, then it is responsible for calling these functions 8152d2369aSRobert Mustacchiappropriately during the transmit and receive paths. 8252d2369aSRobert Mustacchi.Pp 8352d2369aSRobert MustacchiWhile both functions operate on an 8452d2369aSRobert Mustacchi.Sy mblk_t , 8552d2369aSRobert Mustacchithis function should only be called on the first 8652d2369aSRobert Mustacchi.Sy mblk_t 8772d3dbb9SYuri Pankovthat begins a given individual frame in a chain. 8872d3dbb9SYuri PankovIn other words, it only works on entries where it is the first of many possible 8972d3dbb9SYuri Pankoventries linked together by the 9052d2369aSRobert Mustacchi.Sy b_cont 9172d3dbb9SYuri Pankovmember. 9272d3dbb9SYuri PankovThe first 9352d2369aSRobert Mustacchi.Sy mblk_t 9452d2369aSRobert Mustacchireceived from any 9552d2369aSRobert Mustacchi.Xr mac 9E 9652d2369aSRobert MustacchiAPI or pointed to by a 9752d2369aSRobert Mustacchi.Sy b_next 9852d2369aSRobert Mustacchipointer should be used. 9952d2369aSRobert Mustacchi.Ss Receiving Data 10052d2369aSRobert MustacchiWhen a device driver is receiving data, it is its responsibility to 10152d2369aSRobert Mustacchi.Em set 10252d2369aSRobert Mustacchichecksum information when it has indicated that it supports the 10352d2369aSRobert Mustacchi.Sy MAC_CAPAB_HCKSUM 10472d3dbb9SYuri Pankovcapability. 10572d3dbb9SYuri PankovDevice drivers will call the 10652d2369aSRobert Mustacchi.Fn mac_hcksum_set 10752d2369aSRobert Mustacchifunction to indicate what checksum information has occurred. 10852d2369aSRobert Mustacchi.Pp 10972d3dbb9SYuri PankovThe proper values to set depend on the flags passed in. 11072d3dbb9SYuri PankovThe following flags are supported when receiving data, note that they may have 11172d3dbb9SYuri Pankovdifferent meanings from when transmitting data. 11272d3dbb9SYuri PankovThe driver should set the 11352d2369aSRobert Mustacchi.Fa flags 11452d2369aSRobert Mustacchiargument to the bitwise inclusive OR of the following values: 11552d2369aSRobert Mustacchi.Bl -tag -width Sy 11652d2369aSRobert Mustacchi.It Sy HCK_IPV4_HDRCKSUM_OK 11752d2369aSRobert MustacchiThis flag indicates that the hardware has verified the IPv4 header is 11852d2369aSRobert Mustacchicorrect and that the networking stack does not need to verify it. 11952d2369aSRobert Mustacchi.It Sy HCK_PARTIALCKSUM 12052d2369aSRobert MustacchiThis flag indicates that the hardware has computed a partial checksum. 12152d2369aSRobert MustacchiWhen this flag is set, the driver is responsible for passing in the 12252d2369aSRobert Mustacchipartial checksum in the 12352d2369aSRobert Mustacchi.Fa value 12452d2369aSRobert Mustacchiargument as well as the start and ending bytes of the checksum in the 12552d2369aSRobert Mustacchi.Fa start 12652d2369aSRobert Mustacchiand 12752d2369aSRobert Mustacchi.Fa end 12852d2369aSRobert Mustacchiarguments. 12952d2369aSRobert Mustacchi.It Sy HCK_FULLCKSUM 13052d2369aSRobert MustacchiThis flag indicates that the hardware has calculated the full L4 header 13172d3dbb9SYuri Pankovchecksum; however, it wants the system to verify it. 13272d3dbb9SYuri PankovThe checksum should be passed in the 13352d2369aSRobert Mustacchi.Fa value 13452d2369aSRobert Mustacchiargument. 13552d2369aSRobert Mustacchi.It Sy HCK_FULLCKSUM_OK 13652d2369aSRobert MustacchiThis flag indicates that the hardware has calculated the full L4 header 13772d3dbb9SYuri Pankovchecksum and verified that it is correct. 13872d3dbb9SYuri PankovThe networking stack does not need to verify it. 13952d2369aSRobert Mustacchi.El 14052d2369aSRobert Mustacchi.Pp 14152d2369aSRobert MustacchiThe 14252d2369aSRobert Mustacchi.Sy HCK_PARTIALCKSUM , 14352d2369aSRobert Mustacchi.Sy HCK_FULLCKSUM , 14452d2369aSRobert Mustacchiand 14552d2369aSRobert Mustacchi.Sy HCK_FULLCKSUM_OK 14672d3dbb9SYuri Pankovflags are all mutually exclusive. 14772d3dbb9SYuri PankovA device driver should only set one of the three flags. 14852d2369aSRobert Mustacchi.Pp 14952d2369aSRobert MustacchiIf one of the arguments is not required based on the specified value of 15052d2369aSRobert Mustacchi.Fa flags , 15152d2369aSRobert Mustacchithen the device driver should set any remaining arguments to 15252d2369aSRobert Mustacchi.Sy 0 . 15352d2369aSRobert Mustacchi.Ss Transmitting Data 15452d2369aSRobert MustacchiWhen a device driver is transmitting data and it has advertised that it 15552d2369aSRobert Mustacchisupports the 15652d2369aSRobert Mustacchi.Sy MAC_CAPAB_HCKSUM 15752d2369aSRobert Mustacchicapability, then it must call the 15852d2369aSRobert Mustacchi.Fn mac_hcksum_get 15952d2369aSRobert Mustacchifunction to determine what hardware checksumming options are required to 16072d3dbb9SYuri Pankovbe performed by the hardware. 16172d3dbb9SYuri PankovWhile the device driver may need the other fields, it must check the 16252d2369aSRobert Mustacchi.Fa flags 16372d3dbb9SYuri Pankovargument to determine what it is being requested to do. 16472d3dbb9SYuri PankovThe following values may be set in 16552d2369aSRobert Mustacchi.Fa flags : 16652d2369aSRobert Mustacchi.Bl -tag -width Sy 16752d2369aSRobert Mustacchi.It Sy HCK_IPV4_HDRCKSUM 16872d3dbb9SYuri PankovThe device driver must compute the IPv4 header checksum. 16972d3dbb9SYuri PankovNo other fields have been filled in. 17052d2369aSRobert Mustacchi.It Sy HCK_PARTIALCKSUM 17152d2369aSRobert MustacchiThe device driver needs to compute the partial ones' complement of the 17272d3dbb9SYuri Pankovchecksum. 17372d3dbb9SYuri PankovThe system has filled in the 17452d2369aSRobert Mustacchi.Fa start , 17552d2369aSRobert Mustacchi.Fa stuff , 17652d2369aSRobert Mustacchiand 17752d2369aSRobert Mustacchi.Fa end 17852d2369aSRobert Mustacchiarguments to assist the device driver. 17952d2369aSRobert Mustacchi.It Sy HCK_FULLCKSUM 18072d3dbb9SYuri PankovThe device driver should compute the full L4 checksum. 18172d3dbb9SYuri PankovNo other fields have been filled in for the device driver. 18252d2369aSRobert Mustacchi.El 18352d2369aSRobert Mustacchi.Pp 18452d2369aSRobert MustacchiThe flags that the device driver will get will depend on what the device 18552d2369aSRobert Mustacchidriver has advertised that it supports in response to the 18652d2369aSRobert Mustacchi.Xr mc_getcapab 9E 18752d2369aSRobert Mustacchiquery for the 18852d2369aSRobert Mustacchi.Sy MAC_CAPAB_HCKSUM 18952d2369aSRobert Mustacchicapability. 19052d2369aSRobert Mustacchi.Pp 19152d2369aSRobert MustacchiThe 19252d2369aSRobert Mustacchi.Sy HCK_PARTIALCKSUM 19352d2369aSRobert Mustacchiand 19452d2369aSRobert Mustacchi.Sy HCK_FULLCKSUM 19552d2369aSRobert Mustacchiflags are mutually exclusive. 19652d2369aSRobert Mustacchi.Sh CONTEXT 19752d2369aSRobert MustacchiThe 19852d2369aSRobert Mustacchi.Fn mac_hcksum_get 19952d2369aSRobert Mustacchiand 20052d2369aSRobert Mustacchi.Fn mac_hcksum_set 20152d2369aSRobert Mustacchifunctions may be called from any context. 20252d2369aSRobert Mustacchi.Sh SEE ALSO 20352d2369aSRobert Mustacchi.Xr mac 9E , 204b31ca922SChris Fraire.Xr mc_getcapab 9E , 20552d2369aSRobert Mustacchi.Xr mblk 9S 206