net/iavf: enable more link speed
authorQi Zhang <qi.z.zhang@intel.com>
Sat, 4 May 2019 14:09:10 +0000 (22:09 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 May 2019 10:01:56 +0000 (12:01 +0200)
Enable advanced link speed mode (VIRTCHNL_VF_CAP_ADV_LINK_SPEED) so iavf
PMD can identify more link speed that reported by pf.

Cc: stable@dpdk.org
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Wei Zhao <wei.zhao1@intel.com>
drivers/net/iavf/base/virtchnl.h
drivers/net/iavf/iavf.h
drivers/net/iavf/iavf_ethdev.c
drivers/net/iavf/iavf_vchnl.c

index 13bfdb8..10b6538 100644 (file)
@@ -258,6 +258,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 | \
@@ -562,10 +564,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;
+                       u8 link_status;
                } link_event;
+               struct {
+                       /* link_speed provided in Mbps */
+                       u32 link_speed;
+                       u8 link_status;
+               } link_event_adv;
        } event_data;
 
        int severity;
index f1bc99c..3470e03 100644 (file)
@@ -101,7 +101,7 @@ struct iavf_info {
        /* Event from pf */
        bool dev_closed;
        bool link_up;
-       enum virtchnl_link_speed link_speed;
+       uint32_t link_speed;
 
        struct iavf_vsi vsi;
        bool vf_reset;
index 0111ce4..4072a7b 100644 (file)
@@ -586,24 +586,33 @@ iavf_dev_link_update(struct rte_eth_dev *dev,
         *  when receive LINK_CHANGE evnet from PF by Virtchnnl.
         */
        switch (vf->link_speed) {
-       case VIRTCHNL_LINK_SPEED_100MB:
+       case 10:
+               new_link.link_speed = ETH_SPEED_NUM_10M;
+               break;
+       case 100:
                new_link.link_speed = ETH_SPEED_NUM_100M;
                break;
-       case VIRTCHNL_LINK_SPEED_1GB:
+       case 1000:
                new_link.link_speed = ETH_SPEED_NUM_1G;
                break;
-       case VIRTCHNL_LINK_SPEED_10GB:
+       case 10000:
                new_link.link_speed = ETH_SPEED_NUM_10G;
                break;
-       case VIRTCHNL_LINK_SPEED_20GB:
+       case 20000:
                new_link.link_speed = ETH_SPEED_NUM_20G;
                break;
-       case VIRTCHNL_LINK_SPEED_25GB:
+       case 25000:
                new_link.link_speed = ETH_SPEED_NUM_25G;
                break;
-       case VIRTCHNL_LINK_SPEED_40GB:
+       case 40000:
                new_link.link_speed = ETH_SPEED_NUM_40G;
                break;
+       case 50000:
+               new_link.link_speed = ETH_SPEED_NUM_50G;
+               break;
+       case 100000:
+               new_link.link_speed = ETH_SPEED_NUM_100G;
+               break;
        default:
                new_link.link_speed = ETH_SPEED_NUM_NONE;
                break;
index 6381fb6..da6401d 100644 (file)
@@ -153,7 +153,7 @@ iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
        case VIRTCHNL_EVENT_LINK_CHANGE:
                PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
                vf->link_up = pf_msg->event_data.link_event.link_status;
-               vf->link_speed = pf_msg->event_data.link_event.link_speed;
+               vf->link_speed = pf_msg->event_data.link_event_adv.link_speed;
                iavf_dev_link_update(dev, 0);
                _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
                                              NULL);
@@ -344,7 +344,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
         * add advanced/optional offload capabilities
         */
 
-       caps = IAVF_BASIC_OFFLOAD_CAPS;
+       caps = IAVF_BASIC_OFFLOAD_CAPS | VIRTCHNL_VF_CAP_ADV_LINK_SPEED;
 
        args.in_args = (uint8_t *)&caps;
        args.in_args_size = sizeof(caps);