Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
0004  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
0005  */
0006 #ifndef _CQ_ENET_DESC_H_
0007 #define _CQ_ENET_DESC_H_
0008 
0009 #include "cq_desc.h"
0010 
0011 /* Ethernet completion queue descriptor: 16B */
0012 struct cq_enet_wq_desc {
0013     __le16 completed_index;
0014     __le16 q_number;
0015     u8 reserved[11];
0016     u8 type_color;
0017 };
0018 
0019 static inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc,
0020     u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
0021 {
0022     cq_desc_dec((struct cq_desc *)desc, type,
0023         color, q_number, completed_index);
0024 }
0025 
0026 /* Completion queue descriptor: Ethernet receive queue, 16B */
0027 struct cq_enet_rq_desc {
0028     __le16 completed_index_flags;
0029     __le16 q_number_rss_type_flags;
0030     __le32 rss_hash;
0031     __le16 bytes_written_flags;
0032     __le16 vlan;
0033     __le16 checksum_fcoe;
0034     u8 flags;
0035     u8 type_color;
0036 };
0037 
0038 #define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT          (0x1 << 12)
0039 #define CQ_ENET_RQ_DESC_FLAGS_FCOE                  (0x1 << 13)
0040 #define CQ_ENET_RQ_DESC_FLAGS_EOP                   (0x1 << 14)
0041 #define CQ_ENET_RQ_DESC_FLAGS_SOP                   (0x1 << 15)
0042 
0043 #define CQ_ENET_RQ_DESC_RSS_TYPE_BITS               4
0044 #define CQ_ENET_RQ_DESC_RSS_TYPE_MASK \
0045     ((1 << CQ_ENET_RQ_DESC_RSS_TYPE_BITS) - 1)
0046 #define CQ_ENET_RQ_DESC_RSS_TYPE_NONE               0
0047 #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv4               1
0048 #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4           2
0049 #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6               3
0050 #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6           4
0051 #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX            5
0052 #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX        6
0053 
0054 #define CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC         (0x1 << 14)
0055 
0056 #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS          14
0057 #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK \
0058     ((1 << CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS) - 1)
0059 #define CQ_ENET_RQ_DESC_FLAGS_TRUNCATED             (0x1 << 14)
0060 #define CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED         (0x1 << 15)
0061 
0062 #define CQ_ENET_RQ_DESC_FCOE_SOF_BITS               4
0063 #define CQ_ENET_RQ_DESC_FCOE_SOF_MASK \
0064     ((1 << CQ_ENET_RQ_DESC_FCOE_SOF_BITS) - 1)
0065 #define CQ_ENET_RQ_DESC_FCOE_EOF_BITS               8
0066 #define CQ_ENET_RQ_DESC_FCOE_EOF_MASK \
0067     ((1 << CQ_ENET_RQ_DESC_FCOE_EOF_BITS) - 1)
0068 #define CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT              8
0069 
0070 #define CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK       (0x1 << 0)
0071 #define CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK              (0x1 << 0)
0072 #define CQ_ENET_RQ_DESC_FLAGS_UDP                   (0x1 << 1)
0073 #define CQ_ENET_RQ_DESC_FCOE_ENC_ERROR              (0x1 << 1)
0074 #define CQ_ENET_RQ_DESC_FLAGS_TCP                   (0x1 << 2)
0075 #define CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK          (0x1 << 3)
0076 #define CQ_ENET_RQ_DESC_FLAGS_IPV6                  (0x1 << 4)
0077 #define CQ_ENET_RQ_DESC_FLAGS_IPV4                  (0x1 << 5)
0078 #define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT         (0x1 << 6)
0079 #define CQ_ENET_RQ_DESC_FLAGS_FCS_OK                (0x1 << 7)
0080 
0081 static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
0082     u8 *type, u8 *color, u16 *q_number, u16 *completed_index,
0083     u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type,
0084     u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error,
0085     u8 *vlan_stripped, u16 *vlan, u16 *checksum, u8 *fcoe_sof,
0086     u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof,
0087     u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok,
0088     u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok)
0089 {
0090     u16 completed_index_flags = le16_to_cpu(desc->completed_index_flags);
0091     u16 q_number_rss_type_flags =
0092         le16_to_cpu(desc->q_number_rss_type_flags);
0093     u16 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags);
0094 
0095     cq_desc_dec((struct cq_desc *)desc, type,
0096         color, q_number, completed_index);
0097 
0098     *ingress_port = (completed_index_flags &
0099         CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0;
0100     *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ?
0101         1 : 0;
0102     *eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ?
0103         1 : 0;
0104     *sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ?
0105         1 : 0;
0106 
0107     *rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) &
0108         CQ_ENET_RQ_DESC_RSS_TYPE_MASK);
0109     *csum_not_calc = (q_number_rss_type_flags &
0110         CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0;
0111 
0112     *rss_hash = le32_to_cpu(desc->rss_hash);
0113 
0114     *bytes_written = bytes_written_flags &
0115         CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
0116     *packet_error = (bytes_written_flags &
0117         CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0;
0118     *vlan_stripped = (bytes_written_flags &
0119         CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0;
0120 
0121     *vlan = le16_to_cpu(desc->vlan);
0122 
0123     if (*fcoe) {
0124         *fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) &
0125             CQ_ENET_RQ_DESC_FCOE_SOF_MASK);
0126         *fcoe_fc_crc_ok = (desc->flags &
0127             CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0;
0128         *fcoe_enc_error = (desc->flags &
0129             CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0;
0130         *fcoe_eof = (u8)((desc->checksum_fcoe >>
0131             CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) &
0132             CQ_ENET_RQ_DESC_FCOE_EOF_MASK);
0133         *checksum = 0;
0134     } else {
0135         *fcoe_sof = 0;
0136         *fcoe_fc_crc_ok = 0;
0137         *fcoe_enc_error = 0;
0138         *fcoe_eof = 0;
0139         *checksum = le16_to_cpu(desc->checksum_fcoe);
0140     }
0141 
0142     *tcp_udp_csum_ok =
0143         (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0;
0144     *udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0;
0145     *tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0;
0146     *ipv4_csum_ok =
0147         (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0;
0148     *ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0;
0149     *ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0;
0150     *ipv4_fragment =
0151         (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0;
0152     *fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0;
0153 }
0154 
0155 #endif /* _CQ_ENET_DESC_H_ */