net/iavf: implement power management
authorDavid Hunt <david.hunt@intel.com>
Thu, 11 Mar 2021 11:55:10 +0000 (11:55 +0000)
committerQi Zhang <qi.z.zhang@intel.com>
Mon, 29 Mar 2021 23:17:15 +0000 (01:17 +0200)
Implement support for the power management API by implementing a
`get_monitor_addr` function that will return an address of an RX ring's
status bit.

This patch is basically a cut-and-paste of the changes already
committed in ixgbe, i40e and ice drivers in 21.02. This extends
the availability of the power-saving mechanism to the iavf driver,
which is needed for those use-cases using virtual functions.

Patchset where PMD Power Management added in 21.02:
http://patchwork.dpdk.org/project/dpdk/list/?series=14756

Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
drivers/net/iavf/iavf_ethdev.c
drivers/net/iavf/iavf_rxtx.c
drivers/net/iavf/iavf_rxtx.h

index 3ce5b33..869c4a1 100644 (file)
@@ -195,6 +195,7 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
        .rx_queue_intr_disable      = iavf_dev_rx_queue_intr_disable,
        .flow_ops_get               = iavf_dev_flow_ops_get,
        .tx_done_cleanup            = iavf_dev_tx_done_cleanup,
+       .get_monitor_addr           = iavf_get_monitor_addr,
 };
 
 static int
index 8fafe45..caf14a2 100644 (file)
@@ -57,6 +57,31 @@ iavf_proto_xtr_type_to_rxdid(uint8_t flex_type)
                                rxdid_map[flex_type] : IAVF_RXDID_COMMS_OVS_1;
 }
 
+int
+iavf_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
+{
+       struct iavf_rx_queue *rxq = rx_queue;
+       volatile union iavf_rx_desc *rxdp;
+       uint16_t desc;
+
+       desc = rxq->rx_tail;
+       rxdp = &rxq->rx_ring[desc];
+       /* watch for changes in status bit */
+       pmc->addr = &rxdp->wb.qword1.status_error_len;
+
+       /*
+        * we expect the DD bit to be set to 1 if this descriptor was already
+        * written to.
+        */
+       pmc->val = rte_cpu_to_le_64(1 << IAVF_RX_DESC_STATUS_DD_SHIFT);
+       pmc->mask = rte_cpu_to_le_64(1 << IAVF_RX_DESC_STATUS_DD_SHIFT);
+
+       /* registers are 64-bit */
+       pmc->size = sizeof(uint64_t);
+
+       return 0;
+}
+
 static inline int
 check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
 {
index 922ddad..5377459 100644 (file)
@@ -469,6 +469,7 @@ uint16_t iavf_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
                            uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
                                 uint16_t nb_pkts);
+int iavf_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc);
 int iavf_rx_vec_dev_check(struct rte_eth_dev *dev);
 int iavf_tx_vec_dev_check(struct rte_eth_dev *dev);
 int iavf_rxq_vec_setup(struct iavf_rx_queue *rxq);