ethdev: allow drivers to return error on close
[dpdk.git] / drivers / net / i40e / base / virtchnl.h
index 88096cb..9c64fd4 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2020 Intel Corporation
  */
 
 #ifndef _VIRTCHNL_H_
 /* Error Codes */
 enum virtchnl_status_code {
        VIRTCHNL_STATUS_SUCCESS                         = 0,
-       VIRTCHNL_ERR_PARAM                              = -5,
+       VIRTCHNL_STATUS_ERR_PARAM                       = -5,
+       VIRTCHNL_STATUS_ERR_NO_MEMORY                   = -18,
        VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH             = -38,
        VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR             = -39,
        VIRTCHNL_STATUS_ERR_INVALID_VF_ID               = -40,
-       VIRTCHNL_STATUS_NOT_SUPPORTED                   = -64,
+       VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR           = -53,
+       VIRTCHNL_STATUS_ERR_NOT_SUPPORTED               = -64,
 };
 
+/* Backward compatibility */
+#define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
+#define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
+
+#define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT                0x0
 #define VIRTCHNL_LINK_SPEED_100MB_SHIFT                0x1
 #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT       0x2
 #define VIRTCHNL_LINK_SPEED_10GB_SHIFT         0x3
 #define VIRTCHNL_LINK_SPEED_40GB_SHIFT         0x4
 #define VIRTCHNL_LINK_SPEED_20GB_SHIFT         0x5
 #define VIRTCHNL_LINK_SPEED_25GB_SHIFT         0x6
+#define VIRTCHNL_LINK_SPEED_5GB_SHIFT          0x7
 
 enum virtchnl_link_speed {
        VIRTCHNL_LINK_SPEED_UNKNOWN     = 0,
@@ -62,6 +70,8 @@ enum virtchnl_link_speed {
        VIRTCHNL_LINK_SPEED_40GB        = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT),
        VIRTCHNL_LINK_SPEED_20GB        = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT),
        VIRTCHNL_LINK_SPEED_25GB        = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT),
+       VIRTCHNL_LINK_SPEED_2_5GB       = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT),
+       VIRTCHNL_LINK_SPEED_5GB         = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT),
 };
 
 /* for hsplit_0 field of Rx HMC context */
@@ -123,13 +133,13 @@ enum virtchnl_ops {
 
 };
 
-/* This macro is used to generate a compilation error if a structure
+/* These macros are used to generate compilation errors if a structure/union
  * is not exactly the correct length. It gives a divide by zero error if the
  * structure is not of the correct size, otherwise it creates an enum that is
  * never used.
  */
 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
-       {virtchnl_static_assert_##X = (n) / ((sizeof(struct X) == (n)) ? 1 : 0)}
+       { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
 
 /* Virtual channel message descriptor. This overlays the admin queue
  * descriptor. All other data is passed in external buffers.
@@ -222,6 +232,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_RSS_REG            0x00000010
 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR          0x00000020
 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES         0x00000040
+#define VIRTCHNL_VF_OFFLOAD_CRC                        0x00000080
 #define VIRTCHNL_VF_OFFLOAD_VLAN               0x00010000
 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING         0x00020000
 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2      0x00040000
@@ -229,7 +240,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_ENCAP              0X00100000
 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM         0X00200000
 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM      0X00400000
-
+/* Define below the capability flags that are not offloads */
+#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED         0x00000080
 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
                               VIRTCHNL_VF_OFFLOAD_VLAN | \
                               VIRTCHNL_VF_OFFLOAD_RSS_PF)
@@ -270,7 +282,13 @@ VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
  * VF sends this message to set up parameters for one RX queue.
  * External data buffer contains one instance of virtchnl_rxq_info.
- * PF configures requested queue and returns a status code.
+ * PF configures requested queue and returns a status code. The
+ * crc_disable flag disables CRC stripping on the VF. Setting
+ * the crc_disable flag to 1 will disable CRC stripping for each
+ * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
+ * offload must have been set prior to sending this info or the PF
+ * will ignore the request. This flag should be set the same for
+ * all of the queues for a VF.
  */
 
 /* Rx queue config info */
@@ -282,7 +300,8 @@ struct virtchnl_rxq_info {
        u16 splithdr_enabled; /* deprecated with AVF 1.0 */
        u32 databuffer_size;
        u32 max_pkt_size;
-       u32 pad1;
+       u8 crc_disable;
+       u8 pad1[3];
        u64 dma_ring_addr;
        enum virtchnl_rx_hsplit rx_split_pos; /* deprecated with AVF 1.0 */
        u32 pad2;
@@ -518,10 +537,23 @@ enum virtchnl_event_codes {
 struct virtchnl_pf_event {
        enum virtchnl_event_codes event;
        union {
+               /* If the PF driver does not support the new speed reporting
+                * capabilities then use link_event else use link_event_adv to
+                * get the speed and link information. The ability to understand
+                * new speeds is indicated by setting the capability flag
+                * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
+                * in virtchnl_vf_resource struct and can be used to determine
+                * which link event struct to use below.
+                */
                struct {
                        enum virtchnl_link_speed link_speed;
                        bool link_status;
                } link_event;
+               struct {
+                       /* link_speed provided in Mbps */
+                       u32 link_speed;
+                       u8 link_status;
+               } link_event_adv;
        } event_data;
 
        int severity;
@@ -732,7 +764,7 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
        case VIRTCHNL_OP_EVENT:
        case VIRTCHNL_OP_UNKNOWN:
        default:
-               return VIRTCHNL_ERR_PARAM;
+               return VIRTCHNL_STATUS_ERR_PARAM;
        }
        /* few more checks */
        if (err_msg_format || valid_len != msglen)