net/mvpp2: apply flow control after port init
authorLiron Himi <lironh@marvell.com>
Wed, 27 Jan 2021 16:09:42 +0000 (18:09 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 29 Jan 2021 17:16:11 +0000 (18:16 +0100)
In case ppio was not initialized yet (only at 'start' function)
the flow-ctrl setting should be saved for later stage.

Signed-off-by: Liron Himi <lironh@marvell.com>
drivers/net/mvpp2/mrvl_ethdev.c
drivers/net/mvpp2/mrvl_ethdev.h

index b50fda5..fa5e6f7 100644 (file)
@@ -164,6 +164,8 @@ static int
 mrvl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
 static int mrvl_promiscuous_enable(struct rte_eth_dev *dev);
 static int mrvl_allmulticast_enable(struct rte_eth_dev *dev);
+static int
+mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
 
 #define MRVL_XSTATS_TBL_ENTRY(name) { \
        #name, offsetof(struct pp2_ppio_statistics, name),      \
@@ -915,6 +917,15 @@ mrvl_dev_start(struct rte_eth_dev *dev)
        if (dev->data->promiscuous == 1)
                mrvl_promiscuous_enable(dev);
 
+       if (priv->flow_ctrl) {
+               ret = mrvl_flow_ctrl_set(dev, &priv->fc_conf);
+               if (ret) {
+                       MRVL_LOG(ERR, "Failed to configure flow control");
+                       goto out;
+               }
+               priv->flow_ctrl = 0;
+       }
+
        if (dev->data->dev_link.link_status == ETH_LINK_UP) {
                ret = mrvl_dev_set_link_up(dev);
                if (ret) {
@@ -2150,8 +2161,10 @@ mrvl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret, en;
 
-       if (!priv)
-               return -EPERM;
+       if (!priv->ppio) {
+               memcpy(fc_conf, &priv->fc_conf, sizeof(struct rte_eth_fc_conf));
+               return 0;
+       }
 
        fc_conf->autoneg = 1;
        ret = pp2_ppio_get_rx_pause(priv->ppio, &en);
@@ -2197,9 +2210,6 @@ mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
        int ret;
        int rx_en, tx_en;
 
-       if (!priv)
-               return -EPERM;
-
        if (fc_conf->high_water ||
            fc_conf->low_water ||
            fc_conf->pause_time ||
@@ -2214,6 +2224,12 @@ mrvl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
                return -EINVAL;
        }
 
+       if (!priv->ppio) {
+               memcpy(&priv->fc_conf, fc_conf, sizeof(struct rte_eth_fc_conf));
+               priv->flow_ctrl = 1;
+               return 0;
+       }
+
        switch (fc_conf->mode) {
        case RTE_FC_FULL:
                rx_en = 1;
index 42b0cc0..0ee7208 100644 (file)
@@ -160,6 +160,8 @@ struct mrvl_priv {
        uint8_t isolated;
        uint8_t multiseg;
        uint16_t max_mtu;
+       uint8_t flow_ctrl;
+       struct rte_eth_fc_conf fc_conf;
 
        struct pp2_ppio_params ppio_params;
        struct pp2_cls_qos_tbl_params qos_tbl_params;