net/qede: fix VF MTU update
authorRasesh Mody <rasesh.mody@cavium.com>
Tue, 22 May 2018 23:16:03 +0000 (16:16 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 14 Jun 2018 17:27:50 +0000 (19:27 +0200)
This patch fixes VF MTU update to work without having to restart the
vport and there by not requiring port re-configuration. It adds a
VF MTU Update TLV to achieve the same. Firmware can handle VF MTU update
by just pausing the vport.

Fixes: dd28bc8c6ef4 ("net/qede: fix VF port creation sequence")
Cc: stable@dpdk.org
Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
drivers/net/qede/base/ecore_sriov.c
drivers/net/qede/base/ecore_vf.c
drivers/net/qede/base/ecore_vf.h
drivers/net/qede/base/ecore_vfpf_if.h
drivers/net/qede/qede_ethdev.c
drivers/net/qede/qede_ethdev.h

index 451aabb..b6997b8 100644 (file)
@@ -61,6 +61,8 @@ const char *ecore_channel_tlvs_string[] = {
        "CHANNEL_TLV_COALESCE_UPDATE",
        "CHANNEL_TLV_QID",
        "CHANNEL_TLV_COALESCE_READ",
+       "CHANNEL_TLV_BULLETIN_UPDATE_MAC",
+       "CHANNEL_TLV_UPDATE_MTU",
        "CHANNEL_TLV_MAX"
 };
 
@@ -2858,6 +2860,45 @@ out:
                               length, status);
 }
 
+static enum _ecore_status_t
+ecore_iov_vf_pf_update_mtu(struct ecore_hwfn *p_hwfn,
+                                   struct ecore_ptt *p_ptt,
+                                   struct ecore_vf_info *p_vf)
+{
+       struct ecore_iov_vf_mbx *mbx = &p_vf->vf_mbx;
+       struct ecore_sp_vport_update_params params;
+       enum _ecore_status_t rc = ECORE_SUCCESS;
+       struct vfpf_update_mtu_tlv *p_req;
+       u8 status = PFVF_STATUS_SUCCESS;
+
+       /* Valiate PF can send such a request */
+       if (!p_vf->vport_instance) {
+               DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                          "No VPORT instance available for VF[%d], failing MTU update\n",
+                          p_vf->abs_vf_id);
+               status = PFVF_STATUS_FAILURE;
+               goto send_status;
+       }
+
+       p_req = &mbx->req_virt->update_mtu;
+
+       OSAL_MEMSET(&params, 0, sizeof(params));
+       params.opaque_fid =  p_vf->opaque_fid;
+       params.vport_id = p_vf->vport_id;
+       params.mtu = p_req->mtu;
+       rc = ecore_sp_vport_update(p_hwfn, &params, ECORE_SPQ_MODE_EBLOCK,
+                                  OSAL_NULL);
+
+       if (rc)
+               status = PFVF_STATUS_FAILURE;
+send_status:
+       ecore_iov_prepare_resp(p_hwfn, p_ptt, p_vf,
+                              CHANNEL_TLV_UPDATE_MTU,
+                              sizeof(struct pfvf_def_resp_tlv),
+                              status);
+       return rc;
+}
+
 void *ecore_iov_search_list_tlvs(struct ecore_hwfn *p_hwfn,
                                 void *p_tlvs_list, u16 req_type)
 {
@@ -4140,6 +4181,9 @@ void ecore_iov_process_mbx_req(struct ecore_hwfn *p_hwfn,
                case CHANNEL_TLV_COALESCE_READ:
                        ecore_iov_vf_pf_get_coalesce(p_hwfn, p_ptt, p_vf);
                        break;
+               case CHANNEL_TLV_UPDATE_MTU:
+                       ecore_iov_vf_pf_update_mtu(p_hwfn, p_ptt, p_vf);
+                       break;
                }
        } else if (ecore_iov_tlv_supported(mbx->first_tlv.tl.type)) {
                /* If we've received a message from a VF we consider malicious
index b7b3b87..94e09c3 100644 (file)
@@ -1628,6 +1628,39 @@ exit:
        return rc;
 }
 
+enum _ecore_status_t
+ecore_vf_pf_update_mtu(struct ecore_hwfn *p_hwfn, u16 mtu)
+{
+       struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
+       struct vfpf_update_mtu_tlv *p_req;
+       struct pfvf_def_resp_tlv *p_resp;
+       enum _ecore_status_t rc;
+
+       if (!mtu)
+               return ECORE_INVAL;
+
+       /* clear mailbox and prep header tlv */
+       p_req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_UPDATE_MTU,
+                                sizeof(*p_req));
+       p_req->mtu = mtu;
+       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                  "Requesting MTU update to %d\n", mtu);
+
+       /* add list termination tlv */
+       ecore_add_tlv(&p_iov->offset,
+                     CHANNEL_TLV_LIST_END,
+                     sizeof(struct channel_list_end_tlv));
+
+       p_resp = &p_iov->pf2vf_reply->default_resp;
+       rc = ecore_send_msg2pf(p_hwfn, &p_resp->hdr.status, sizeof(*p_resp));
+       if (p_resp->hdr.status == PFVF_STATUS_NOT_SUPPORTED)
+               rc = ECORE_INVAL;
+
+       ecore_vf_pf_req_end(p_hwfn, rc);
+
+       return rc;
+}
+
 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
                           u16               sb_id)
 {
index e26b30b..52c630f 100644 (file)
@@ -319,5 +319,14 @@ void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun);
 
 u32 ecore_vf_hw_bar_size(struct ecore_hwfn *p_hwfn,
                     enum BAR_ID bar_id);
+
+/**
+ * @brief - ecore_vf_pf_update_mtu Update MTU for VF.
+ *
+ * @param p_hwfn
+ * @param - mtu
+ */
+enum _ecore_status_t
+ecore_vf_pf_update_mtu(struct ecore_hwfn *p_hwfn, u16 mtu);
 #endif
 #endif /* __ECORE_VF_H__ */
index dce937e..c8828ad 100644 (file)
@@ -531,6 +531,18 @@ struct pfvf_read_coal_resp_tlv {
        u8 padding[6];
 };
 
+struct vfpf_bulletin_update_mac_tlv {
+       struct vfpf_first_tlv first_tlv;
+       u8 mac[ETH_ALEN];
+       u8 padding[2];
+};
+
+struct vfpf_update_mtu_tlv {
+       struct vfpf_first_tlv first_tlv;
+       u16 mtu;
+       u8 padding[6];
+};
+
 union vfpf_tlvs {
        struct vfpf_first_tlv                   first_tlv;
        struct vfpf_acquire_tlv                 acquire;
@@ -545,6 +557,8 @@ union vfpf_tlvs {
        struct vfpf_update_tunn_param_tlv       tunn_param_update;
        struct vfpf_update_coalesce             update_coalesce;
        struct vfpf_read_coal_req_tlv           read_coal_req;
+       struct vfpf_bulletin_update_mac_tlv     bulletin_update_mac;
+       struct vfpf_update_mtu_tlv              update_mtu;
        struct tlv_buffer_size                  tlv_buf_size;
 };
 
@@ -675,6 +689,8 @@ enum {
        CHANNEL_TLV_COALESCE_UPDATE,
        CHANNEL_TLV_QID,
        CHANNEL_TLV_COALESCE_READ,
+       CHANNEL_TLV_BULLETIN_UPDATE_MAC,
+       CHANNEL_TLV_UPDATE_MTU,
        CHANNEL_TLV_MAX,
 
        /* Required for iterating over vport-update tlvs.
index 3206cc6..8f37139 100644 (file)
@@ -603,37 +603,6 @@ int qede_enable_tpa(struct rte_eth_dev *eth_dev, bool flg)
        return 0;
 }
 
-/* Update MTU via vport-update without doing port restart.
- * The vport must be deactivated before calling this API.
- */
-int qede_update_mtu(struct rte_eth_dev *eth_dev, uint16_t mtu)
-{
-       struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
-       struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
-       struct ecore_sp_vport_update_params params;
-       struct ecore_hwfn *p_hwfn;
-       int rc;
-       int i;
-
-       memset(&params, 0, sizeof(struct ecore_sp_vport_update_params));
-       params.vport_id = 0;
-       params.mtu = mtu;
-       params.vport_id = 0;
-       for_each_hwfn(edev, i) {
-               p_hwfn = &edev->hwfns[i];
-               params.opaque_fid = p_hwfn->hw_info.opaque_fid;
-               rc = ecore_sp_vport_update(p_hwfn, &params,
-                               ECORE_SPQ_MODE_EBLOCK, NULL);
-               if (rc != ECORE_SUCCESS) {
-                       DP_ERR(edev, "Failed to update MTU\n");
-                       return -1;
-               }
-       }
-       DP_INFO(edev, "MTU updated to %u\n", mtu);
-
-       return 0;
-}
-
 static void qede_set_ucast_cmn_params(struct ecore_filter_ucast *ucast)
 {
        memset(ucast, 0, sizeof(struct ecore_filter_ucast));
@@ -1296,6 +1265,12 @@ static int qede_dev_start(struct rte_eth_dev *eth_dev)
 
        PMD_INIT_FUNC_TRACE(edev);
 
+       /* Update MTU only if it has changed */
+       if (eth_dev->data->mtu != qdev->mtu) {
+               if (qede_update_mtu(eth_dev, qdev->mtu))
+                       goto err;
+       }
+
        /* Configure TPA parameters */
        if (rxmode->offloads & DEV_RX_OFFLOAD_TCP_LRO) {
                if (qede_enable_tpa(eth_dev, true))
@@ -2056,6 +2031,72 @@ qede_set_mc_addr_list(struct rte_eth_dev *eth_dev, struct ether_addr *mc_addrs,
        return qede_add_mcast_filters(eth_dev, mc_addrs, mc_addrs_num);
 }
 
+/* Update MTU via vport-update without doing port restart.
+ * The vport must be deactivated before calling this API.
+ */
+int qede_update_mtu(struct rte_eth_dev *eth_dev, uint16_t mtu)
+{
+       struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
+       struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
+       struct ecore_hwfn *p_hwfn;
+       int rc;
+       int i;
+
+       if (IS_PF(edev)) {
+               struct ecore_sp_vport_update_params params;
+
+               memset(&params, 0, sizeof(struct ecore_sp_vport_update_params));
+               params.vport_id = 0;
+               params.mtu = mtu;
+               params.vport_id = 0;
+               for_each_hwfn(edev, i) {
+                       p_hwfn = &edev->hwfns[i];
+                       params.opaque_fid = p_hwfn->hw_info.opaque_fid;
+                       rc = ecore_sp_vport_update(p_hwfn, &params,
+                                       ECORE_SPQ_MODE_EBLOCK, NULL);
+                       if (rc != ECORE_SUCCESS)
+                               goto err;
+               }
+       } else {
+               for_each_hwfn(edev, i) {
+                       p_hwfn = &edev->hwfns[i];
+                       rc = ecore_vf_pf_update_mtu(p_hwfn, mtu);
+                       if (rc == ECORE_INVAL) {
+                               DP_INFO(edev, "VF MTU Update TLV not supported\n");
+                               /* Recreate vport */
+                               rc = qede_start_vport(qdev, mtu);
+                               if (rc != ECORE_SUCCESS)
+                                       goto err;
+
+                               /* Restore config lost due to vport stop */
+                               qede_mac_addr_set(eth_dev, &qdev->primary_mac);
+
+                               if (eth_dev->data->promiscuous)
+                                       qede_promiscuous_enable(eth_dev);
+                               else
+                                       qede_promiscuous_disable(eth_dev);
+
+                               if (eth_dev->data->all_multicast)
+                                       qede_allmulticast_enable(eth_dev);
+                               else
+                                       qede_allmulticast_disable(eth_dev);
+
+                               qede_vlan_offload_set(eth_dev,
+                                                     qdev->vlan_offload_mask);
+                       } else if (rc != ECORE_SUCCESS) {
+                               goto err;
+                       }
+               }
+       }
+       DP_INFO(edev, "%s MTU updated to %u\n", IS_PF(edev) ? "PF" : "VF", mtu);
+
+       return 0;
+
+err:
+       DP_ERR(edev, "Failed to update MTU\n");
+       return -1;
+}
+
 static int qede_flow_ctrl_set(struct rte_eth_dev *eth_dev,
                              struct rte_eth_fc_conf *fc_conf)
 {
@@ -2463,7 +2504,6 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
                        qede_mac_addr_remove(dev, 0);
        }
        rte_delay_ms(1000);
-       qede_start_vport(qdev, mtu); /* Recreate vport */
        qdev->mtu = mtu;
 
        /* Fix up RX buf size for all queues of the port */
@@ -2487,22 +2527,6 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
        else
                dev->data->dev_conf.rxmode.jumbo_frame = 0;
 
-       /* Restore config lost due to vport stop */
-       if (IS_PF(edev))
-               qede_mac_addr_set(dev, &qdev->primary_mac);
-
-       if (dev->data->promiscuous)
-               qede_promiscuous_enable(dev);
-       else
-               qede_promiscuous_disable(dev);
-
-       if (dev->data->all_multicast)
-               qede_allmulticast_enable(dev);
-       else
-               qede_allmulticast_disable(dev);
-
-       qede_vlan_offload_set(dev, qdev->vlan_offload_mask);
-
        if (!dev->data->dev_started && restart) {
                qede_dev_start(dev);
                dev->data->dev_started = 1;
index a335d4d..9b80011 100644 (file)
@@ -34,6 +34,7 @@
 #include "base/nvm_cfg.h"
 #include "base/ecore_sp_commands.h"
 #include "base/ecore_l2.h"
+#include "base/ecore_vf.h"
 
 #include "qede_logs.h"
 #include "qede_if.h"