18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc. All rights reserved. 38c2ecf20Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc. All rights reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is free software; you may redistribute it and/or modify 68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 78c2ecf20Sopenharmony_ci * the Free Software Foundation; version 2 of the License. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 108c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 118c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 128c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 138c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 158c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 168c2ecf20Sopenharmony_ci * SOFTWARE. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#ifndef _CQ_ENET_DESC_H_ 198c2ecf20Sopenharmony_ci#define _CQ_ENET_DESC_H_ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include "cq_desc.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* Ethernet completion queue descriptor: 16B */ 248c2ecf20Sopenharmony_cistruct cq_enet_wq_desc { 258c2ecf20Sopenharmony_ci __le16 completed_index; 268c2ecf20Sopenharmony_ci __le16 q_number; 278c2ecf20Sopenharmony_ci u8 reserved[11]; 288c2ecf20Sopenharmony_ci u8 type_color; 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc, 328c2ecf20Sopenharmony_ci u8 *type, u8 *color, u16 *q_number, u16 *completed_index) 338c2ecf20Sopenharmony_ci{ 348c2ecf20Sopenharmony_ci cq_desc_dec((struct cq_desc *)desc, type, 358c2ecf20Sopenharmony_ci color, q_number, completed_index); 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* Completion queue descriptor: Ethernet receive queue, 16B */ 398c2ecf20Sopenharmony_cistruct cq_enet_rq_desc { 408c2ecf20Sopenharmony_ci __le16 completed_index_flags; 418c2ecf20Sopenharmony_ci __le16 q_number_rss_type_flags; 428c2ecf20Sopenharmony_ci __le32 rss_hash; 438c2ecf20Sopenharmony_ci __le16 bytes_written_flags; 448c2ecf20Sopenharmony_ci __le16 vlan; 458c2ecf20Sopenharmony_ci __le16 checksum_fcoe; 468c2ecf20Sopenharmony_ci u8 flags; 478c2ecf20Sopenharmony_ci u8 type_color; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT (0x1 << 12) 518c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_FCOE (0x1 << 13) 528c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_EOP (0x1 << 14) 538c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_SOP (0x1 << 15) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_BITS 4 568c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_MASK \ 578c2ecf20Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_RSS_TYPE_BITS) - 1) 588c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_NONE 0 598c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv4 1 608c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4 2 618c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6 3 628c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6 4 638c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX 5 648c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX 6 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC (0x1 << 14) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS 14 698c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK \ 708c2ecf20Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS) - 1) 718c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_TRUNCATED (0x1 << 14) 728c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED (0x1 << 15) 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_SOF_BITS 4 758c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_SOF_MASK \ 768c2ecf20Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_FCOE_SOF_BITS) - 1) 778c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_EOF_BITS 8 788c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_EOF_MASK \ 798c2ecf20Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_FCOE_EOF_BITS) - 1) 808c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT 8 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK (0x1 << 0) 838c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK (0x1 << 0) 848c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_UDP (0x1 << 1) 858c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_ENC_ERROR (0x1 << 1) 868c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_TCP (0x1 << 2) 878c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK (0x1 << 3) 888c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV6 (0x1 << 4) 898c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV4 (0x1 << 5) 908c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT (0x1 << 6) 918c2ecf20Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_FCS_OK (0x1 << 7) 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc, 948c2ecf20Sopenharmony_ci u8 *type, u8 *color, u16 *q_number, u16 *completed_index, 958c2ecf20Sopenharmony_ci u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type, 968c2ecf20Sopenharmony_ci u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error, 978c2ecf20Sopenharmony_ci u8 *vlan_stripped, u16 *vlan, u16 *checksum, u8 *fcoe_sof, 988c2ecf20Sopenharmony_ci u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof, 998c2ecf20Sopenharmony_ci u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok, 1008c2ecf20Sopenharmony_ci u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok) 1018c2ecf20Sopenharmony_ci{ 1028c2ecf20Sopenharmony_ci u16 completed_index_flags = le16_to_cpu(desc->completed_index_flags); 1038c2ecf20Sopenharmony_ci u16 q_number_rss_type_flags = 1048c2ecf20Sopenharmony_ci le16_to_cpu(desc->q_number_rss_type_flags); 1058c2ecf20Sopenharmony_ci u16 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci cq_desc_dec((struct cq_desc *)desc, type, 1088c2ecf20Sopenharmony_ci color, q_number, completed_index); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci *ingress_port = (completed_index_flags & 1118c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0; 1128c2ecf20Sopenharmony_ci *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ? 1138c2ecf20Sopenharmony_ci 1 : 0; 1148c2ecf20Sopenharmony_ci *eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ? 1158c2ecf20Sopenharmony_ci 1 : 0; 1168c2ecf20Sopenharmony_ci *sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ? 1178c2ecf20Sopenharmony_ci 1 : 0; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci *rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) & 1208c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_RSS_TYPE_MASK); 1218c2ecf20Sopenharmony_ci *csum_not_calc = (q_number_rss_type_flags & 1228c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci *rss_hash = le32_to_cpu(desc->rss_hash); 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci *bytes_written = bytes_written_flags & 1278c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK; 1288c2ecf20Sopenharmony_ci *packet_error = (bytes_written_flags & 1298c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0; 1308c2ecf20Sopenharmony_ci *vlan_stripped = (bytes_written_flags & 1318c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci *vlan = le16_to_cpu(desc->vlan); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci if (*fcoe) { 1368c2ecf20Sopenharmony_ci *fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) & 1378c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_SOF_MASK); 1388c2ecf20Sopenharmony_ci *fcoe_fc_crc_ok = (desc->flags & 1398c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0; 1408c2ecf20Sopenharmony_ci *fcoe_enc_error = (desc->flags & 1418c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0; 1428c2ecf20Sopenharmony_ci *fcoe_eof = (u8)((desc->checksum_fcoe >> 1438c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) & 1448c2ecf20Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_EOF_MASK); 1458c2ecf20Sopenharmony_ci *checksum = 0; 1468c2ecf20Sopenharmony_ci } else { 1478c2ecf20Sopenharmony_ci *fcoe_sof = 0; 1488c2ecf20Sopenharmony_ci *fcoe_fc_crc_ok = 0; 1498c2ecf20Sopenharmony_ci *fcoe_enc_error = 0; 1508c2ecf20Sopenharmony_ci *fcoe_eof = 0; 1518c2ecf20Sopenharmony_ci *checksum = le16_to_cpu(desc->checksum_fcoe); 1528c2ecf20Sopenharmony_ci } 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci *tcp_udp_csum_ok = 1558c2ecf20Sopenharmony_ci (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0; 1568c2ecf20Sopenharmony_ci *udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0; 1578c2ecf20Sopenharmony_ci *tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0; 1588c2ecf20Sopenharmony_ci *ipv4_csum_ok = 1598c2ecf20Sopenharmony_ci (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0; 1608c2ecf20Sopenharmony_ci *ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0; 1618c2ecf20Sopenharmony_ci *ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0; 1628c2ecf20Sopenharmony_ci *ipv4_fragment = 1638c2ecf20Sopenharmony_ci (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0; 1648c2ecf20Sopenharmony_ci *fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0; 1658c2ecf20Sopenharmony_ci} 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#endif /* _CQ_ENET_DESC_H_ */ 168