net/i40e/base: support FCoE
authorQi Zhang <qi.z.zhang@intel.com>
Thu, 25 Aug 2016 20:05:18 +0000 (16:05 -0400)
committerBruce Richardson <bruce.richardson@intel.com>
Fri, 30 Sep 2016 10:27:18 +0000 (12:27 +0200)
Add Fibre Channel Over Ethernet (FCoE) in PHY capabilities.
Add data structure for FCoE statistics collection.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/i40e/base/i40e_adminq_cmd.h
drivers/net/i40e/base/i40e_type.h

index 36e1569..4f06772 100644 (file)
@@ -1768,6 +1768,8 @@ struct i40e_aq_get_phy_abilities_resp {
 #define I40E_AQ_PHY_LINK_ENABLED       0x08
 #define I40E_AQ_PHY_AN_ENABLED         0x10
 #define I40E_AQ_PHY_FLAG_MODULE_QUAL   0x20
+#define I40E_AQ_PHY_FEC_ABILITY_KR     0x40
+#define I40E_AQ_PHY_FEC_ABILITY_RS     0x80
        __le16  eee_capability;
 #define I40E_AQ_EEE_100BASE_TX         0x0002
 #define I40E_AQ_EEE_1000BASE_T         0x0004
@@ -1811,7 +1813,13 @@ struct i40e_aq_set_phy_config { /* same bits as above in all */
 #define I40E_AQ_PHY_TYPE_EXT_25G_CR    0X02
 #define I40E_AQ_PHY_TYPE_EXT_25G_SR    0x04
 #define I40E_AQ_PHY_TYPE_EXT_25G_LR    0x08
-       u8      reserved[2];
+       u8      fec_config;
+#define I40E_AQ_SET_FEC_ABILITY_KR     (1 << 0)
+#define I40E_AQ_SET_FEC_ABILITY_RS     (1 << 1)
+#define I40E_AQ_SET_FEC_REQUEST_KR     (1 << 2)
+#define I40E_AQ_SET_FEC_REQUEST_RS     (1 << 3)
+#define I40E_AQ_SET_FEC_AUTO           (1 << 4)
+       u8      reserved;
 };
 
 I40E_CHECK_CMD_LENGTH(i40e_aq_set_phy_config);
@@ -1901,6 +1909,8 @@ struct i40e_aqc_get_link_status {
        u8      loopback; /* use defines from i40e_aqc_set_lb_mode */
        __le16  max_frame_size;
        u8      config;
+#define I40E_AQ_CONFIG_FEC_KR_ENA      0x01
+#define I40E_AQ_CONFIG_FEC_RS_ENA      0x02
 #define I40E_AQ_CONFIG_CRC_ENA         0x04
 #define I40E_AQ_CONFIG_PACING_MASK     0x78
        u8      power_desc;
index de3cb2b..b5f72c3 100644 (file)
@@ -1392,6 +1392,23 @@ struct i40e_veb_tc_stats {
        u64 tc_tx_bytes[I40E_MAX_TRAFFIC_CLASS];
 };
 
+/* Statistics collected per function for FCoE */
+struct i40e_fcoe_stats {
+       u64 rx_fcoe_packets;            /* fcoeprc */
+       u64 rx_fcoe_dwords;             /* focedwrc */
+       u64 rx_fcoe_dropped;            /* fcoerpdc */
+       u64 tx_fcoe_packets;            /* fcoeptc */
+       u64 tx_fcoe_dwords;             /* focedwtc */
+       u64 fcoe_bad_fccrc;             /* fcoecrc */
+       u64 fcoe_last_error;            /* fcoelast */
+       u64 fcoe_ddp_count;             /* fcoeddpc */
+};
+
+/* offset to per function FCoE statistics block */
+#define I40E_FCOE_VF_STAT_OFFSET       0
+#define I40E_FCOE_PF_STAT_OFFSET       128
+#define I40E_FCOE_STAT_MAX             (I40E_FCOE_PF_STAT_OFFSET + I40E_MAX_PF)
+
 /* Statistics collected by the MAC */
 struct i40e_hw_port_stats {
        /* eth stats collected by the port */
@@ -1513,6 +1530,208 @@ struct i40e_hw_port_stats {
 
 #define I40E_SRRD_SRCTL_ATTEMPTS       100000
 
+/* FCoE Tx context descriptor - Use the i40e_tx_context_desc struct */
+
+enum i40E_fcoe_tx_ctx_desc_cmd_bits {
+       I40E_FCOE_TX_CTX_DESC_OPCODE_SINGLE_SEND        = 0x00, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_TSO_FC_CLASS2      = 0x01, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_TSO_FC_CLASS3      = 0x05, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_ETSO_FC_CLASS2     = 0x02, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_ETSO_FC_CLASS3     = 0x06, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_DWO_FC_CLASS2      = 0x03, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_DWO_FC_CLASS3      = 0x07, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_DDP_CTX_INVL       = 0x08, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_OPCODE_DWO_CTX_INVL       = 0x09, /* 4 BITS */
+       I40E_FCOE_TX_CTX_DESC_RELOFF                    = 0x10,
+       I40E_FCOE_TX_CTX_DESC_CLRSEQ                    = 0x20,
+       I40E_FCOE_TX_CTX_DESC_DIFENA                    = 0x40,
+       I40E_FCOE_TX_CTX_DESC_IL2TAG2                   = 0x80
+};
+
+/* FCoE DIF/DIX Context descriptor */
+struct i40e_fcoe_difdix_context_desc {
+       __le64 flags_buff0_buff1_ref;
+       __le64 difapp_msk_bias;
+};
+
+#define I40E_FCOE_DIFDIX_CTX_QW0_FLAGS_SHIFT   0
+#define I40E_FCOE_DIFDIX_CTX_QW0_FLAGS_MASK    (0xFFFULL << \
+                                       I40E_FCOE_DIFDIX_CTX_QW0_FLAGS_SHIFT)
+
+enum i40e_fcoe_difdix_ctx_desc_flags_bits {
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_RSVD                          = 0x0000,
+       /* 1 BIT  */
+       I40E_FCOE_DIFDIX_CTX_DESC_APPTYPE_TAGCHK                = 0x0000,
+       /* 1 BIT  */
+       I40E_FCOE_DIFDIX_CTX_DESC_APPTYPE_TAGNOTCHK             = 0x0004,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_GTYPE_OPAQUE                  = 0x0000,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_GTYPE_CHKINTEGRITY            = 0x0008,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_GTYPE_CHKINTEGRITY_APPTAG     = 0x0010,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_GTYPE_CHKINTEGRITY_APPREFTAG  = 0x0018,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_REFTYPE_CNST                  = 0x0000,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_REFTYPE_INC1BLK               = 0x0020,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_REFTYPE_APPTAG                = 0x0040,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_REFTYPE_RSVD                  = 0x0060,
+       /* 1 BIT  */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIXMODE_XSUM                  = 0x0000,
+       /* 1 BIT  */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIXMODE_CRC                   = 0x0080,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFHOST_UNTAG                 = 0x0000,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFHOST_BUF                   = 0x0100,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFHOST_RSVD                  = 0x0200,
+       /* 2 BITS */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFHOST_EMBDTAGS              = 0x0300,
+       /* 1 BIT  */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFLAN_UNTAG                  = 0x0000,
+       /* 1 BIT  */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFLAN_TAG                    = 0x0400,
+       /* 1 BIT */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFBLK_512B                   = 0x0000,
+       /* 1 BIT */
+       I40E_FCOE_DIFDIX_CTX_DESC_DIFBLK_4K                     = 0x0800
+};
+
+#define I40E_FCOE_DIFDIX_CTX_QW0_BUFF0_SHIFT   12
+#define I40E_FCOE_DIFDIX_CTX_QW0_BUFF0_MASK    (0x3FFULL << \
+                                       I40E_FCOE_DIFDIX_CTX_QW0_BUFF0_SHIFT)
+
+#define I40E_FCOE_DIFDIX_CTX_QW0_BUFF1_SHIFT   22
+#define I40E_FCOE_DIFDIX_CTX_QW0_BUFF1_MASK    (0x3FFULL << \
+                                       I40E_FCOE_DIFDIX_CTX_QW0_BUFF1_SHIFT)
+
+#define I40E_FCOE_DIFDIX_CTX_QW0_REF_SHIFT     32
+#define I40E_FCOE_DIFDIX_CTX_QW0_REF_MASK      (0xFFFFFFFFULL << \
+                                       I40E_FCOE_DIFDIX_CTX_QW0_REF_SHIFT)
+
+#define I40E_FCOE_DIFDIX_CTX_QW1_APP_SHIFT     0
+#define I40E_FCOE_DIFDIX_CTX_QW1_APP_MASK      (0xFFFFULL << \
+                                       I40E_FCOE_DIFDIX_CTX_QW1_APP_SHIFT)
+
+#define I40E_FCOE_DIFDIX_CTX_QW1_APP_MSK_SHIFT 16
+#define I40E_FCOE_DIFDIX_CTX_QW1_APP_MSK_MASK  (0xFFFFULL << \
+                                       I40E_FCOE_DIFDIX_CTX_QW1_APP_MSK_SHIFT)
+
+#define I40E_FCOE_DIFDIX_CTX_QW1_REF_BIAS_SHIFT        32
+#define I40E_FCOE_DIFDIX_CTX_QW0_REF_BIAS_MASK (0xFFFFFFFFULL << \
+                                       I40E_FCOE_DIFDIX_CTX_QW1_REF_BIAS_SHIFT)
+
+/* FCoE DIF/DIX Buffers descriptor */
+struct i40e_fcoe_difdix_buffers_desc {
+       __le64 buff_addr0;
+       __le64 buff_addr1;
+};
+
+/* FCoE DDP Context descriptor */
+struct i40e_fcoe_ddp_context_desc {
+       __le64 rsvd;
+       __le64 type_cmd_foff_lsize;
+};
+
+#define I40E_FCOE_DDP_CTX_QW1_DTYPE_SHIFT      0
+#define I40E_FCOE_DDP_CTX_QW1_DTYPE_MASK       (0xFULL << \
+                                       I40E_FCOE_DDP_CTX_QW1_DTYPE_SHIFT)
+
+#define I40E_FCOE_DDP_CTX_QW1_CMD_SHIFT        4
+#define I40E_FCOE_DDP_CTX_QW1_CMD_MASK (0xFULL << \
+                                        I40E_FCOE_DDP_CTX_QW1_CMD_SHIFT)
+
+enum i40e_fcoe_ddp_ctx_desc_cmd_bits {
+       I40E_FCOE_DDP_CTX_DESC_BSIZE_512B       = 0x00, /* 2 BITS */
+       I40E_FCOE_DDP_CTX_DESC_BSIZE_4K         = 0x01, /* 2 BITS */
+       I40E_FCOE_DDP_CTX_DESC_BSIZE_8K         = 0x02, /* 2 BITS */
+       I40E_FCOE_DDP_CTX_DESC_BSIZE_16K        = 0x03, /* 2 BITS */
+       I40E_FCOE_DDP_CTX_DESC_DIFENA           = 0x04, /* 1 BIT  */
+       I40E_FCOE_DDP_CTX_DESC_LASTSEQH         = 0x08, /* 1 BIT  */
+};
+
+#define I40E_FCOE_DDP_CTX_QW1_FOFF_SHIFT       16
+#define I40E_FCOE_DDP_CTX_QW1_FOFF_MASK        (0x3FFFULL << \
+                                        I40E_FCOE_DDP_CTX_QW1_FOFF_SHIFT)
+
+#define I40E_FCOE_DDP_CTX_QW1_LSIZE_SHIFT      32
+#define I40E_FCOE_DDP_CTX_QW1_LSIZE_MASK       (0x3FFFULL << \
+                                       I40E_FCOE_DDP_CTX_QW1_LSIZE_SHIFT)
+
+/* FCoE DDP/DWO Queue Context descriptor */
+struct i40e_fcoe_queue_context_desc {
+       __le64 dmaindx_fbase;           /* 0:11 DMAINDX, 12:63 FBASE */
+       __le64 flen_tph;                /* 0:12 FLEN, 13:15 TPH */
+};
+
+#define I40E_FCOE_QUEUE_CTX_QW0_DMAINDX_SHIFT  0
+#define I40E_FCOE_QUEUE_CTX_QW0_DMAINDX_MASK   (0xFFFULL << \
+                                       I40E_FCOE_QUEUE_CTX_QW0_DMAINDX_SHIFT)
+
+#define I40E_FCOE_QUEUE_CTX_QW0_FBASE_SHIFT    12
+#define I40E_FCOE_QUEUE_CTX_QW0_FBASE_MASK     (0xFFFFFFFFFFFFFULL << \
+                                       I40E_FCOE_QUEUE_CTX_QW0_FBASE_SHIFT)
+
+#define I40E_FCOE_QUEUE_CTX_QW1_FLEN_SHIFT     0
+#define I40E_FCOE_QUEUE_CTX_QW1_FLEN_MASK      (0x1FFFULL << \
+                                       I40E_FCOE_QUEUE_CTX_QW1_FLEN_SHIFT)
+
+#define I40E_FCOE_QUEUE_CTX_QW1_TPH_SHIFT      13
+#define I40E_FCOE_QUEUE_CTX_QW1_TPH_MASK       (0x7ULL << \
+                                       I40E_FCOE_QUEUE_CTX_QW1_FLEN_SHIFT)
+
+enum i40e_fcoe_queue_ctx_desc_tph_bits {
+       I40E_FCOE_QUEUE_CTX_DESC_TPHRDESC       = 0x1,
+       I40E_FCOE_QUEUE_CTX_DESC_TPHDATA        = 0x2
+};
+
+#define I40E_FCOE_QUEUE_CTX_QW1_RECIPE_SHIFT   30
+#define I40E_FCOE_QUEUE_CTX_QW1_RECIPE_MASK    (0x3ULL << \
+                                       I40E_FCOE_QUEUE_CTX_QW1_RECIPE_SHIFT)
+
+/* FCoE DDP/DWO Filter Context descriptor */
+struct i40e_fcoe_filter_context_desc {
+       __le32 param;
+       __le16 seqn;
+
+       /* 48:51(0:3) RSVD, 52:63(4:15) DMAINDX */
+       __le16 rsvd_dmaindx;
+
+       /* 0:7 FLAGS, 8:52 RSVD, 53:63 LANQ */
+       __le64 flags_rsvd_lanq;
+};
+
+#define I40E_FCOE_FILTER_CTX_QW0_DMAINDX_SHIFT 4
+#define I40E_FCOE_FILTER_CTX_QW0_DMAINDX_MASK  (0xFFF << \
+                                       I40E_FCOE_FILTER_CTX_QW0_DMAINDX_SHIFT)
+
+enum i40e_fcoe_filter_ctx_desc_flags_bits {
+       I40E_FCOE_FILTER_CTX_DESC_CTYP_DDP      = 0x00,
+       I40E_FCOE_FILTER_CTX_DESC_CTYP_DWO      = 0x01,
+       I40E_FCOE_FILTER_CTX_DESC_ENODE_INIT    = 0x00,
+       I40E_FCOE_FILTER_CTX_DESC_ENODE_RSP     = 0x02,
+       I40E_FCOE_FILTER_CTX_DESC_FC_CLASS2     = 0x00,
+       I40E_FCOE_FILTER_CTX_DESC_FC_CLASS3     = 0x04
+};
+
+#define I40E_FCOE_FILTER_CTX_QW1_FLAGS_SHIFT   0
+#define I40E_FCOE_FILTER_CTX_QW1_FLAGS_MASK    (0xFFULL << \
+                                       I40E_FCOE_FILTER_CTX_QW1_FLAGS_SHIFT)
+
+#define I40E_FCOE_FILTER_CTX_QW1_PCTYPE_SHIFT     8
+#define I40E_FCOE_FILTER_CTX_QW1_PCTYPE_MASK      (0x3FULL << \
+                       I40E_FCOE_FILTER_CTX_QW1_PCTYPE_SHIFT)
+
+#define I40E_FCOE_FILTER_CTX_QW1_LANQINDX_SHIFT     53
+#define I40E_FCOE_FILTER_CTX_QW1_LANQINDX_MASK      (0x7FFULL << \
+                       I40E_FCOE_FILTER_CTX_QW1_LANQINDX_SHIFT)
+
 enum i40e_switch_element_types {
        I40E_SWITCH_ELEMENT_TYPE_MAC    = 1,
        I40E_SWITCH_ELEMENT_TYPE_PF     = 2,