Extract the 'ctrl' data filed into the super class, prepare for the
upcoming common library.

Signed-off-by: Chaoyong He <chaoyong...@corigine.com>
Reviewed-by: Long Wu <long...@corigine.com>
Reviewed-by: Peng Zhang <peng.zh...@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower.c |  8 ++---
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c  |  2 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  |  2 +-
 drivers/net/nfp/nfp_ethdev.c        |  2 +-
 drivers/net/nfp/nfp_ethdev_vf.c     |  2 +-
 drivers/net/nfp/nfp_net_common.c    | 46 ++++++++++++++---------------
 drivers/net/nfp/nfp_net_common.h    |  4 +--
 drivers/net/nfp/nfp_rxtx.c          | 12 ++++----
 8 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c 
b/drivers/net/nfp/flower/nfp_flower.c
index 28bdb8e214..2aa0d9939e 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -61,7 +61,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
        nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
        nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-       new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+       new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
        update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
                        NFP_NET_CFG_UPDATE_MSIX;
 
@@ -72,7 +72,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
        if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
                return;
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 }
 
 int
@@ -123,7 +123,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
                return -EIO;
        }
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 
        /* Setup the freelist ring */
        ret = nfp_net_rx_freelist_setup(dev);
@@ -723,7 +723,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
                return -EIO;
        }
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 
        /* Setup the freelist ring */
        ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c 
b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index e9a16371bc..9f03b56c0c 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -154,7 +154,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw 
*meta_data,
        cap_extend = hw->cap_ext;
 
        if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-                       (hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+                       (hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
                if (meta_data->length == 0)
                        meta_data->length = NFP_NET_META_HEADER_SIZE;
                meta_data->length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c 
b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 533099278d..bc027210af 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -187,7 +187,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
        cap_extend = hw->cap_ext;
 
        if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-                       (hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+                       (hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
                if (meta_data.length == 0)
                        meta_data.length = NFP_NET_META_HEADER_SIZE;
                meta_data.length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 9ff1c297a4..ec9f6041fd 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -167,7 +167,7 @@ nfp_net_start(struct rte_eth_dev *dev)
        else
                nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 
        for (i = 0; i < dev->data->nb_rx_queues; i++)
                dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 641fed6fcf..684968903c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -110,7 +110,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
                goto error;
        }
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 
        for (i = 0; i < dev->data->nb_rx_queues; i++)
                dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 283f5ee627..25b8e3a613 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -500,7 +500,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
        nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
        nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-       new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+       new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
        update = NFP_NET_CFG_UPDATE_GEN |
                        NFP_NET_CFG_UPDATE_RING |
                        NFP_NET_CFG_UPDATE_MSIX;
@@ -512,7 +512,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
        if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
                return;
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 }
 
 void
@@ -553,7 +553,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
        struct nfp_net_hw *hw;
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
                        (hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
                PMD_DRV_LOG(ERR, "MAC address unable to change when port 
enabled");
                return -EBUSY;
@@ -563,8 +563,8 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
        nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
        update = NFP_NET_CFG_UPDATE_MACADDR;
-       ctrl = hw->ctrl;
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+       ctrl = hw->super.ctrl;
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
                        (hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
                ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
@@ -613,7 +613,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
        }
 
        /* Avoiding TX interrupts */
-       hw->ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
+       hw->super.ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
        return 0;
 }
 
@@ -705,19 +705,19 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
                return -ENOTSUP;
        }
 
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
                PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
                return 0;
        }
 
-       new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
+       new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
        update = NFP_NET_CFG_UPDATE_GEN;
 
        ret = nfp_net_reconfig(hw, new_ctrl, update);
        if (ret != 0)
                return ret;
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 
        return 0;
 }
@@ -732,19 +732,19 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev)
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
                PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
                return 0;
        }
 
-       new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+       new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
        update = NFP_NET_CFG_UPDATE_GEN;
 
        ret = nfp_net_reconfig(hw, new_ctrl, update);
        if (ret != 0)
                return ret;
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 
        return 0;
 }
@@ -1349,7 +1349,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
        else
                hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-       hw->ctrl = 0;
+       hw->super.ctrl = 0;
        hw->stride_rx = stride;
        hw->stride_tx = stride;
 
@@ -1453,7 +1453,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
        /* Make sure all updates are written before un-masking */
        rte_wmb();
 
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
                /* If MSI-X auto-masking is used, clear the entry */
                rte_intr_ack(pci_dev->intr_handle);
        } else {
@@ -1559,7 +1559,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        rx_offload = dev->data->dev_conf.rxmode.offloads;
-       new_ctrl = hw->ctrl;
+       new_ctrl = hw->super.ctrl;
 
        /* VLAN stripping setting */
        if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
@@ -1578,7 +1578,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
                        new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
        }
 
-       if (new_ctrl == hw->ctrl)
+       if (new_ctrl == hw->super.ctrl)
                return 0;
 
        update = NFP_NET_CFG_UPDATE_GEN;
@@ -1587,7 +1587,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
        if (ret != 0)
                return ret;
 
-       hw->ctrl = new_ctrl;
+       hw->super.ctrl = new_ctrl;
 
        return 0;
 }
@@ -1660,7 +1660,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
        struct nfp_net_hw *hw;
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
                return -EINVAL;
 
        ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1669,7 +1669,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
        update = NFP_NET_CFG_UPDATE_RSS;
 
-       if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+       if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
                return -EIO;
 
        return 0;
@@ -1690,7 +1690,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
        struct nfp_net_hw *hw;
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
                return -EINVAL;
 
        if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1795,7 +1795,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
        rss_hf = rss_conf->rss_hf;
 
        /* Checking if RSS is enabled */
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
                if (rss_hf != 0) {
                        PMD_DRV_LOG(ERR, "RSS unsupported");
                        return -EINVAL;
@@ -1813,7 +1813,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
        update = NFP_NET_CFG_UPDATE_RSS;
 
-       if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+       if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
                return -EIO;
 
        return 0;
@@ -1831,7 +1831,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
                return -EINVAL;
 
        rss_hf = rss_conf->rss_hf;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 2f02803ea4..375e26bfc2 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -116,6 +116,7 @@ struct nfp_hw {
        uint8_t *ctrl_bar;
        uint8_t *qcp_cfg;
        uint32_t cap;
+       uint32_t ctrl;    /**< Current values for control */
 };
 
 struct nfp_net_hw {
@@ -139,9 +140,6 @@ struct nfp_net_hw {
        /** NFP ASIC params */
        const struct nfp_dev_info *dev_info;
 
-       /** Current values for control */
-       uint32_t ctrl;
-
        uint8_t *tx_bar;
        uint8_t *rx_bar;
 
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a0c7e0e9b5..a9dd464a6a 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -143,7 +143,7 @@ nfp_net_rx_cksum(struct nfp_net_rxq *rxq,
 {
        struct nfp_net_hw *hw = rxq->hw;
 
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
                return;
 
        /* If IPv4 and IP checksum error, fail */
@@ -307,7 +307,7 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
 {
        struct nfp_net_hw *hw = rxq->hw;
 
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
                return;
 
        mbuf->hash.rss = meta->hash;
@@ -339,7 +339,7 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
        struct nfp_net_hw *hw = rxq->hw;
 
        /* Skip if firmware don't support setting vlan. */
-       if ((hw->ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) 
== 0)
+       if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | 
NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
                return;
 
        /*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed 
*meta,
         * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
         * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
         */
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
                if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
                        mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
                        mb->ol_flags |= RTE_MBUF_F_RX_VLAN | 
RTE_MBUF_F_RX_VLAN_STRIPPED;
                }
-       } else if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+       } else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
                if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
                        mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
                        mb->ol_flags |= RTE_MBUF_F_RX_VLAN | 
RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -385,7 +385,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 {
        struct nfp_net_hw *hw = rxq->hw;
 
-       if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+       if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
                        (hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
                return;
 
-- 
2.39.1

Reply via email to