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_EXCH_DESC_H_ 198c2ecf20Sopenharmony_ci#define _CQ_EXCH_DESC_H_ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include "cq_desc.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* Exchange completion queue descriptor: 16B */ 248c2ecf20Sopenharmony_cistruct cq_exch_wq_desc { 258c2ecf20Sopenharmony_ci u16 completed_index; 268c2ecf20Sopenharmony_ci u16 q_number; 278c2ecf20Sopenharmony_ci u16 exchange_id; 288c2ecf20Sopenharmony_ci u8 tmpl; 298c2ecf20Sopenharmony_ci u8 reserved0; 308c2ecf20Sopenharmony_ci u32 reserved1; 318c2ecf20Sopenharmony_ci u8 exch_status; 328c2ecf20Sopenharmony_ci u8 reserved2[2]; 338c2ecf20Sopenharmony_ci u8 type_color; 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define CQ_EXCH_WQ_STATUS_BITS 2 378c2ecf20Sopenharmony_ci#define CQ_EXCH_WQ_STATUS_MASK ((1 << CQ_EXCH_WQ_STATUS_BITS) - 1) 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cienum cq_exch_status_types { 408c2ecf20Sopenharmony_ci CQ_EXCH_WQ_STATUS_TYPE_COMPLETE = 0, 418c2ecf20Sopenharmony_ci CQ_EXCH_WQ_STATUS_TYPE_ABORT = 1, 428c2ecf20Sopenharmony_ci CQ_EXCH_WQ_STATUS_TYPE_SGL_EOF = 2, 438c2ecf20Sopenharmony_ci CQ_EXCH_WQ_STATUS_TYPE_TMPL_ERR = 3, 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic inline void cq_exch_wq_desc_dec(struct cq_exch_wq_desc *desc_ptr, 478c2ecf20Sopenharmony_ci u8 *type, 488c2ecf20Sopenharmony_ci u8 *color, 498c2ecf20Sopenharmony_ci u16 *q_number, 508c2ecf20Sopenharmony_ci u16 *completed_index, 518c2ecf20Sopenharmony_ci u8 *exch_status) 528c2ecf20Sopenharmony_ci{ 538c2ecf20Sopenharmony_ci cq_desc_dec((struct cq_desc *)desc_ptr, type, 548c2ecf20Sopenharmony_ci color, q_number, completed_index); 558c2ecf20Sopenharmony_ci *exch_status = desc_ptr->exch_status & CQ_EXCH_WQ_STATUS_MASK; 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct cq_fcp_rq_desc { 598c2ecf20Sopenharmony_ci u16 completed_index_eop_sop_prt; 608c2ecf20Sopenharmony_ci u16 q_number; 618c2ecf20Sopenharmony_ci u16 exchange_id; 628c2ecf20Sopenharmony_ci u16 tmpl; 638c2ecf20Sopenharmony_ci u16 bytes_written; 648c2ecf20Sopenharmony_ci u16 vlan; 658c2ecf20Sopenharmony_ci u8 sof; 668c2ecf20Sopenharmony_ci u8 eof; 678c2ecf20Sopenharmony_ci u8 fcs_fer_fck; 688c2ecf20Sopenharmony_ci u8 type_color; 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FLAGS_SOP (1 << 15) 728c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FLAGS_EOP (1 << 14) 738c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FLAGS_PRT (1 << 12) 748c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_TMPL_MASK 0x1f 758c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK 0x3fff 768c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT 14 778c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_PACKET_ERR_MASK (1 << CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT) 788c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT 15 798c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_VS_STRIPPED_MASK (1 << CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT) 808c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FC_CRC_OK_MASK 0x1 818c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT 1 828c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FCOE_ERR_MASK (1 << CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT) 838c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FCS_OK_SHIFT 7 848c2ecf20Sopenharmony_ci#define CQ_FCP_RQ_DESC_FCS_OK_MASK (1 << CQ_FCP_RQ_DESC_FCS_OK_SHIFT) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic inline void cq_fcp_rq_desc_dec(struct cq_fcp_rq_desc *desc_ptr, 878c2ecf20Sopenharmony_ci u8 *type, 888c2ecf20Sopenharmony_ci u8 *color, 898c2ecf20Sopenharmony_ci u16 *q_number, 908c2ecf20Sopenharmony_ci u16 *completed_index, 918c2ecf20Sopenharmony_ci u8 *eop, 928c2ecf20Sopenharmony_ci u8 *sop, 938c2ecf20Sopenharmony_ci u8 *fck, 948c2ecf20Sopenharmony_ci u16 *exchange_id, 958c2ecf20Sopenharmony_ci u16 *tmpl, 968c2ecf20Sopenharmony_ci u32 *bytes_written, 978c2ecf20Sopenharmony_ci u8 *sof, 988c2ecf20Sopenharmony_ci u8 *eof, 998c2ecf20Sopenharmony_ci u8 *ingress_port, 1008c2ecf20Sopenharmony_ci u8 *packet_err, 1018c2ecf20Sopenharmony_ci u8 *fcoe_err, 1028c2ecf20Sopenharmony_ci u8 *fcs_ok, 1038c2ecf20Sopenharmony_ci u8 *vlan_stripped, 1048c2ecf20Sopenharmony_ci u16 *vlan) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci cq_desc_dec((struct cq_desc *)desc_ptr, type, 1078c2ecf20Sopenharmony_ci color, q_number, completed_index); 1088c2ecf20Sopenharmony_ci *eop = (desc_ptr->completed_index_eop_sop_prt & 1098c2ecf20Sopenharmony_ci CQ_FCP_RQ_DESC_FLAGS_EOP) ? 1 : 0; 1108c2ecf20Sopenharmony_ci *sop = (desc_ptr->completed_index_eop_sop_prt & 1118c2ecf20Sopenharmony_ci CQ_FCP_RQ_DESC_FLAGS_SOP) ? 1 : 0; 1128c2ecf20Sopenharmony_ci *ingress_port = 1138c2ecf20Sopenharmony_ci (desc_ptr->completed_index_eop_sop_prt & 1148c2ecf20Sopenharmony_ci CQ_FCP_RQ_DESC_FLAGS_PRT) ? 1 : 0; 1158c2ecf20Sopenharmony_ci *exchange_id = desc_ptr->exchange_id; 1168c2ecf20Sopenharmony_ci *tmpl = desc_ptr->tmpl & CQ_FCP_RQ_DESC_TMPL_MASK; 1178c2ecf20Sopenharmony_ci *bytes_written = 1188c2ecf20Sopenharmony_ci desc_ptr->bytes_written & CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK; 1198c2ecf20Sopenharmony_ci *packet_err = 1208c2ecf20Sopenharmony_ci (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_PACKET_ERR_MASK) >> 1218c2ecf20Sopenharmony_ci CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT; 1228c2ecf20Sopenharmony_ci *vlan_stripped = 1238c2ecf20Sopenharmony_ci (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_VS_STRIPPED_MASK) >> 1248c2ecf20Sopenharmony_ci CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT; 1258c2ecf20Sopenharmony_ci *vlan = desc_ptr->vlan; 1268c2ecf20Sopenharmony_ci *sof = desc_ptr->sof; 1278c2ecf20Sopenharmony_ci *fck = desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FC_CRC_OK_MASK; 1288c2ecf20Sopenharmony_ci *fcoe_err = (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCOE_ERR_MASK) >> 1298c2ecf20Sopenharmony_ci CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT; 1308c2ecf20Sopenharmony_ci *eof = desc_ptr->eof; 1318c2ecf20Sopenharmony_ci *fcs_ok = 1328c2ecf20Sopenharmony_ci (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCS_OK_MASK) >> 1338c2ecf20Sopenharmony_ci CQ_FCP_RQ_DESC_FCS_OK_SHIFT; 1348c2ecf20Sopenharmony_ci} 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistruct cq_sgl_desc { 1378c2ecf20Sopenharmony_ci u16 exchange_id; 1388c2ecf20Sopenharmony_ci u16 q_number; 1398c2ecf20Sopenharmony_ci u32 active_burst_offset; 1408c2ecf20Sopenharmony_ci u32 tot_data_bytes; 1418c2ecf20Sopenharmony_ci u16 tmpl; 1428c2ecf20Sopenharmony_ci u8 sgl_err; 1438c2ecf20Sopenharmony_ci u8 type_color; 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cienum cq_sgl_err_types { 1478c2ecf20Sopenharmony_ci CQ_SGL_ERR_NO_ERROR = 0, 1488c2ecf20Sopenharmony_ci CQ_SGL_ERR_OVERFLOW, /* data ran beyond end of SGL */ 1498c2ecf20Sopenharmony_ci CQ_SGL_ERR_SGL_LCL_ADDR_ERR, /* sgl access to local vnic addr illegal*/ 1508c2ecf20Sopenharmony_ci CQ_SGL_ERR_ADDR_RSP_ERR, /* sgl address error */ 1518c2ecf20Sopenharmony_ci CQ_SGL_ERR_DATA_RSP_ERR, /* sgl data rsp error */ 1528c2ecf20Sopenharmony_ci CQ_SGL_ERR_CNT_ZERO_ERR, /* SGL count is 0 */ 1538c2ecf20Sopenharmony_ci CQ_SGL_ERR_CNT_MAX_ERR, /* SGL count is larger than supported */ 1548c2ecf20Sopenharmony_ci CQ_SGL_ERR_ORDER_ERR, /* frames recv on both ports, order err */ 1558c2ecf20Sopenharmony_ci CQ_SGL_ERR_DATA_LCL_ADDR_ERR,/* sgl data buf to local vnic addr ill */ 1568c2ecf20Sopenharmony_ci CQ_SGL_ERR_HOST_CQ_ERR, /* host cq entry to local vnic addr ill */ 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#define CQ_SGL_SGL_ERR_MASK 0x1f 1608c2ecf20Sopenharmony_ci#define CQ_SGL_TMPL_MASK 0x1f 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_cistatic inline void cq_sgl_desc_dec(struct cq_sgl_desc *desc_ptr, 1638c2ecf20Sopenharmony_ci u8 *type, 1648c2ecf20Sopenharmony_ci u8 *color, 1658c2ecf20Sopenharmony_ci u16 *q_number, 1668c2ecf20Sopenharmony_ci u16 *exchange_id, 1678c2ecf20Sopenharmony_ci u32 *active_burst_offset, 1688c2ecf20Sopenharmony_ci u32 *tot_data_bytes, 1698c2ecf20Sopenharmony_ci u16 *tmpl, 1708c2ecf20Sopenharmony_ci u8 *sgl_err) 1718c2ecf20Sopenharmony_ci{ 1728c2ecf20Sopenharmony_ci /* Cheat a little by assuming exchange_id is the same as completed 1738c2ecf20Sopenharmony_ci index */ 1748c2ecf20Sopenharmony_ci cq_desc_dec((struct cq_desc *)desc_ptr, type, color, q_number, 1758c2ecf20Sopenharmony_ci exchange_id); 1768c2ecf20Sopenharmony_ci *active_burst_offset = desc_ptr->active_burst_offset; 1778c2ecf20Sopenharmony_ci *tot_data_bytes = desc_ptr->tot_data_bytes; 1788c2ecf20Sopenharmony_ci *tmpl = desc_ptr->tmpl & CQ_SGL_TMPL_MASK; 1798c2ecf20Sopenharmony_ci *sgl_err = desc_ptr->sgl_err & CQ_SGL_SGL_ERR_MASK; 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci#endif /* _CQ_EXCH_DESC_H_ */ 183