162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc. All rights reserved. 462306a36Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc. All rights reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef _CQ_ENET_DESC_H_ 762306a36Sopenharmony_ci#define _CQ_ENET_DESC_H_ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include "cq_desc.h" 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* Ethernet completion queue descriptor: 16B */ 1262306a36Sopenharmony_cistruct cq_enet_wq_desc { 1362306a36Sopenharmony_ci __le16 completed_index; 1462306a36Sopenharmony_ci __le16 q_number; 1562306a36Sopenharmony_ci u8 reserved[11]; 1662306a36Sopenharmony_ci u8 type_color; 1762306a36Sopenharmony_ci}; 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_cistatic inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc, 2062306a36Sopenharmony_ci u8 *type, u8 *color, u16 *q_number, u16 *completed_index) 2162306a36Sopenharmony_ci{ 2262306a36Sopenharmony_ci cq_desc_dec((struct cq_desc *)desc, type, 2362306a36Sopenharmony_ci color, q_number, completed_index); 2462306a36Sopenharmony_ci} 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* Completion queue descriptor: Ethernet receive queue, 16B */ 2762306a36Sopenharmony_cistruct cq_enet_rq_desc { 2862306a36Sopenharmony_ci __le16 completed_index_flags; 2962306a36Sopenharmony_ci __le16 q_number_rss_type_flags; 3062306a36Sopenharmony_ci __le32 rss_hash; 3162306a36Sopenharmony_ci __le16 bytes_written_flags; 3262306a36Sopenharmony_ci __le16 vlan; 3362306a36Sopenharmony_ci __le16 checksum_fcoe; 3462306a36Sopenharmony_ci u8 flags; 3562306a36Sopenharmony_ci u8 type_color; 3662306a36Sopenharmony_ci}; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT (0x1 << 12) 3962306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_FCOE (0x1 << 13) 4062306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_EOP (0x1 << 14) 4162306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_SOP (0x1 << 15) 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_BITS 4 4462306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_MASK \ 4562306a36Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_RSS_TYPE_BITS) - 1) 4662306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_NONE 0 4762306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv4 1 4862306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4 2 4962306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6 3 5062306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6 4 5162306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX 5 5262306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX 6 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC (0x1 << 14) 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS 14 5762306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK \ 5862306a36Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS) - 1) 5962306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_TRUNCATED (0x1 << 14) 6062306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED (0x1 << 15) 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_SOF_BITS 4 6362306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_SOF_MASK \ 6462306a36Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_FCOE_SOF_BITS) - 1) 6562306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_EOF_BITS 8 6662306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_EOF_MASK \ 6762306a36Sopenharmony_ci ((1 << CQ_ENET_RQ_DESC_FCOE_EOF_BITS) - 1) 6862306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT 8 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK (0x1 << 0) 7162306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK (0x1 << 0) 7262306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_UDP (0x1 << 1) 7362306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FCOE_ENC_ERROR (0x1 << 1) 7462306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_TCP (0x1 << 2) 7562306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK (0x1 << 3) 7662306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV6 (0x1 << 4) 7762306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV4 (0x1 << 5) 7862306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT (0x1 << 6) 7962306a36Sopenharmony_ci#define CQ_ENET_RQ_DESC_FLAGS_FCS_OK (0x1 << 7) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_cistatic inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc, 8262306a36Sopenharmony_ci u8 *type, u8 *color, u16 *q_number, u16 *completed_index, 8362306a36Sopenharmony_ci u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type, 8462306a36Sopenharmony_ci u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error, 8562306a36Sopenharmony_ci u8 *vlan_stripped, u16 *vlan, u16 *checksum, u8 *fcoe_sof, 8662306a36Sopenharmony_ci u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof, 8762306a36Sopenharmony_ci u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok, 8862306a36Sopenharmony_ci u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok) 8962306a36Sopenharmony_ci{ 9062306a36Sopenharmony_ci u16 completed_index_flags = le16_to_cpu(desc->completed_index_flags); 9162306a36Sopenharmony_ci u16 q_number_rss_type_flags = 9262306a36Sopenharmony_ci le16_to_cpu(desc->q_number_rss_type_flags); 9362306a36Sopenharmony_ci u16 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags); 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci cq_desc_dec((struct cq_desc *)desc, type, 9662306a36Sopenharmony_ci color, q_number, completed_index); 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci *ingress_port = (completed_index_flags & 9962306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0; 10062306a36Sopenharmony_ci *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ? 10162306a36Sopenharmony_ci 1 : 0; 10262306a36Sopenharmony_ci *eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ? 10362306a36Sopenharmony_ci 1 : 0; 10462306a36Sopenharmony_ci *sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ? 10562306a36Sopenharmony_ci 1 : 0; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci *rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) & 10862306a36Sopenharmony_ci CQ_ENET_RQ_DESC_RSS_TYPE_MASK); 10962306a36Sopenharmony_ci *csum_not_calc = (q_number_rss_type_flags & 11062306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0; 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci *rss_hash = le32_to_cpu(desc->rss_hash); 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci *bytes_written = bytes_written_flags & 11562306a36Sopenharmony_ci CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK; 11662306a36Sopenharmony_ci *packet_error = (bytes_written_flags & 11762306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0; 11862306a36Sopenharmony_ci *vlan_stripped = (bytes_written_flags & 11962306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci *vlan = le16_to_cpu(desc->vlan); 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci if (*fcoe) { 12462306a36Sopenharmony_ci *fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) & 12562306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_SOF_MASK); 12662306a36Sopenharmony_ci *fcoe_fc_crc_ok = (desc->flags & 12762306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0; 12862306a36Sopenharmony_ci *fcoe_enc_error = (desc->flags & 12962306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0; 13062306a36Sopenharmony_ci *fcoe_eof = (u8)((desc->checksum_fcoe >> 13162306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) & 13262306a36Sopenharmony_ci CQ_ENET_RQ_DESC_FCOE_EOF_MASK); 13362306a36Sopenharmony_ci *checksum = 0; 13462306a36Sopenharmony_ci } else { 13562306a36Sopenharmony_ci *fcoe_sof = 0; 13662306a36Sopenharmony_ci *fcoe_fc_crc_ok = 0; 13762306a36Sopenharmony_ci *fcoe_enc_error = 0; 13862306a36Sopenharmony_ci *fcoe_eof = 0; 13962306a36Sopenharmony_ci *checksum = le16_to_cpu(desc->checksum_fcoe); 14062306a36Sopenharmony_ci } 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci *tcp_udp_csum_ok = 14362306a36Sopenharmony_ci (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0; 14462306a36Sopenharmony_ci *udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0; 14562306a36Sopenharmony_ci *tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0; 14662306a36Sopenharmony_ci *ipv4_csum_ok = 14762306a36Sopenharmony_ci (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0; 14862306a36Sopenharmony_ci *ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0; 14962306a36Sopenharmony_ci *ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0; 15062306a36Sopenharmony_ci *ipv4_fragment = 15162306a36Sopenharmony_ci (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0; 15262306a36Sopenharmony_ci *fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0; 15362306a36Sopenharmony_ci} 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci#endif /* _CQ_ENET_DESC_H_ */ 156