net/sfc: support per-port dynamic logging
[dpdk.git] / drivers / net / sfc / sfc_ethdev.c
index 0fe9bf5..15aee22 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <rte_dev.h>
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
@@ -27,6 +27,8 @@
 #include "sfc_dp.h"
 #include "sfc_dp_rx.h"
 
+uint32_t sfc_logtype_driver;
+
 static struct sfc_dp_list sfc_dp_head =
        TAILQ_HEAD_INITIALIZER(sfc_dp_head);
 
@@ -83,6 +85,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct sfc_adapter *sa = dev->data->dev_private;
        const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+       uint64_t txq_offloads_def = 0;
 
        sfc_log_init(sa, "entry");
 
@@ -114,7 +117,20 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
                                    dev_info->rx_queue_offload_capa;
 
-       dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
+       dev_info->tx_queue_offload_capa = sfc_tx_get_queue_offload_caps(sa);
+
+       /*
+        * tx_offload_capa includes both device and queue offloads since
+        * the latter may be requested on a per device basis which makes
+        * sense when some offloads are needed to be set on all queues.
+        */
+       dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa) |
+                                   dev_info->tx_queue_offload_capa;
+
+       if (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+               txq_offloads_def |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+       dev_info->default_txconf.offloads |= txq_offloads_def;
 
        dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
        if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
@@ -222,22 +238,13 @@ static int
 sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 {
        struct sfc_adapter *sa = dev->data->dev_private;
-       struct rte_eth_link *dev_link = &dev->data->dev_link;
-       struct rte_eth_link old_link;
        struct rte_eth_link current_link;
+       int ret;
 
        sfc_log_init(sa, "entry");
 
-retry:
-       EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t));
-       *(int64_t *)&old_link = rte_atomic64_read((rte_atomic64_t *)dev_link);
-
        if (sa->state != SFC_ADAPTER_STARTED) {
                sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, &current_link);
-               if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link,
-                                        *(uint64_t *)&old_link,
-                                        *(uint64_t *)&current_link))
-                       goto retry;
        } else if (wait_to_complete) {
                efx_link_mode_t link_mode;
 
@@ -245,21 +252,16 @@ retry:
                        link_mode = EFX_LINK_UNKNOWN;
                sfc_port_link_mode_to_info(link_mode, &current_link);
 
-               if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link,
-                                        *(uint64_t *)&old_link,
-                                        *(uint64_t *)&current_link))
-                       goto retry;
        } else {
                sfc_ev_mgmt_qpoll(sa);
-               *(int64_t *)&current_link =
-                       rte_atomic64_read((rte_atomic64_t *)dev_link);
+               rte_eth_linkstatus_get(dev, &current_link);
        }
 
-       if (old_link.link_status != current_link.link_status)
+       ret = rte_eth_linkstatus_set(dev, &current_link);
+       if (ret == 0)
                sfc_info(sa, "Link status is %s",
                         current_link.link_status ? "UP" : "DOWN");
-
-       return old_link.link_status == current_link.link_status ? 0 : -1;
+       return ret;
 }
 
 static void
@@ -1081,6 +1083,7 @@ sfc_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
        memset(qinfo, 0, sizeof(*qinfo));
 
        qinfo->conf.txq_flags = txq_info->txq->flags;
+       qinfo->conf.offloads = txq_info->txq->offloads;
        qinfo->conf.tx_free_thresh = txq_info->txq->free_thresh;
        qinfo->conf.tx_deferred_start = txq_info->deferred_start;
        qinfo->nb_desc = txq_info->entries;
@@ -1920,6 +1923,9 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
        /* Copy PCI device info to the dev->data */
        rte_eth_copy_pci_info(dev, pci_dev);
 
+       sa->logtype_main = sfc_register_logtype(sa, SFC_LOGTYPE_MAIN_STR,
+                                               RTE_LOG_NOTICE);
+
        rc = sfc_kvargs_parse(sa);
        if (rc != 0)
                goto fail_kvargs_parse;
@@ -2067,3 +2073,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx,
        SFC_KVARG_STATS_UPDATE_PERIOD_MS "=<long> "
        SFC_KVARG_MCDI_LOGGING "=" SFC_KVARG_VALUES_BOOL " "
        SFC_KVARG_DEBUG_INIT "=" SFC_KVARG_VALUES_BOOL);
+
+RTE_INIT(sfc_driver_register_logtype);
+static void
+sfc_driver_register_logtype(void)
+{
+       int ret;
+
+       ret = rte_log_register_type_and_pick_level(SFC_LOGTYPE_PREFIX "driver",
+                                                  RTE_LOG_NOTICE);
+       sfc_logtype_driver = (ret < 0) ? RTE_LOGTYPE_PMD : ret;
+}