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]
23 * Copyright 2014 QLogic Corporation
24 * The contents of this file are subject to the terms of the
25 * QLogic End User License (the "License").
26 * You may not use this file except in compliance with the License.
28 * You can obtain a copy of the License at
29 * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
30 * QLogic_End_User_Software_License.txt
31 * See the License for the specific language governing permissions
32 * and limitations under the License.
36 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
41 int BnxeRouteTxRing(um_device_t
* pUM
,
44 u32_t numRings
= pUM
->devParams
.numRings
;
58 * Need enough space to cover the ethernet header (+vlan), max ip header,
59 * and the first 4 bytes of the TCP/IP header (src/dst ports).
62 uint8_t hdrs_buf
[sizeof(struct ether_vlan_header
) +
66 switch (pUM
->devParams
.routeTxRingPolicy
)
68 case BNXE_ROUTE_RING_TCPUDP
:
72 etype
= ntohs(((struct ether_header
*)pHdr
)->ether_type
);
74 if (etype
== ETHERTYPE_VLAN
)
76 etype
= ntohs(((struct ether_vlan_header
*)pHdr
)->ether_type
);
77 eHdrSize
= sizeof(struct ether_vlan_header
);
81 eHdrSize
= sizeof(struct ether_header
);
84 if (etype
== ETHERTYPE_IP
)
86 mblkLen
= MBLKL(pMblk
);
89 if (mblkLen
> (eHdrSize
+ sizeof(uint8_t)))
91 pHdr
= (pMblk
->b_rptr
+ eHdrSize
);
94 pHdr
= (mblkLen
> (((*pHdr
& 0x0f) << 2) + sizeof(uint32_t))) ?
100 /* copy the header so it's contiguous in the local hdrs_buf */
104 while (pTmpMblk
&& (hdrs_size
< sizeof(hdrs_buf
)))
106 mblkLen
= MBLKL(pTmpMblk
);
108 if (mblkLen
>= (sizeof(hdrs_buf
) - hdrs_size
))
110 mblkLen
= (sizeof(hdrs_buf
) - hdrs_size
);
113 bcopy(pTmpMblk
->b_rptr
, &hdrs_buf
[hdrs_size
], mblkLen
);
115 hdrs_size
+= mblkLen
;
116 pTmpMblk
= pTmpMblk
->b_cont
;
124 if (!(pHdr
[6] & 0x3f) && !(pHdr
[7] & 0xff))
132 /* source and destination ports */
133 pHdr
+= (((*pHdr
) & 0x0f) << 2);
134 ring
= ((u32_t
)(pHdr
[0] ^ pHdr
[1] ^ pHdr
[2] ^ pHdr
[3]) %
140 /* security parameters index */
141 pHdr
+= (((*pHdr
) & 0x0f) << 2);
142 ring
= ((pHdr
[4] ^ pHdr
[5] ^ pHdr
[6] ^ pHdr
[7]) %
148 /* last byte of the destination IP address */
149 ring
= (pHdr
[19] % numRings
);
155 /* fragmented packet */
156 ring
= (pHdr
[19] % numRings
);
161 ring
= (pMblk
->b_band
% numRings
);
166 case BNXE_ROUTE_RING_DEST_MAC
:
168 /* last byte of dst mac addr */
169 pHdr
= pMblk
->b_rptr
;
170 ring
= (pHdr
[5] % numRings
);
173 case BNXE_ROUTE_RING_MSG_PRIO
:
175 ring
= (pMblk
->b_band
% numRings
);
178 case BNXE_ROUTE_RING_NONE
: