net/sfc: start to factor out multi-process shared data
[dpdk.git] / drivers / net / sfc / sfc_ethdev.c
index 5bc73d5..88dbecd 100644 (file)
@@ -442,7 +442,7 @@ sfc_rx_queue_release(void *queue)
        sa = rxq->evq->sa;
        sfc_adapter_lock(sa);
 
-       sw_index = sfc_rxq_sw_index(rxq);
+       sw_index = dp_rxq->dpq.queue_id;
 
        sfc_log_init(sa, "RxQ=%u", sw_index);
 
@@ -468,7 +468,7 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
        if (rc != 0)
                goto fail_tx_qinit;
 
-       dev->data->tx_queues[tx_queue_id] = sa->txq_info[tx_queue_id].txq->dp;
+       dev->data->tx_queues[tx_queue_id] = sa->txq_info[tx_queue_id].dp;
 
        sfc_adapter_unlock(sa);
        return 0;
@@ -491,7 +491,7 @@ sfc_tx_queue_release(void *queue)
                return;
 
        txq = sfc_txq_by_dp_txq(dp_txq);
-       sw_index = sfc_txq_sw_index(txq);
+       sw_index = dp_txq->dpq.queue_id;
 
        SFC_ASSERT(txq->evq != NULL);
        sa = txq->evq->sa;
@@ -1167,13 +1167,19 @@ sfc_rx_descriptor_status(void *queue, uint16_t offset)
        return dp_rx->qdesc_status(dp_rxq, offset);
 }
 
+/*
+ * The function is used by the secondary process as well. It must not
+ * use any process-local pointers from the adapter data.
+ */
 static int
 sfc_tx_descriptor_status(void *queue, uint16_t offset)
 {
        struct sfc_dp_txq *dp_txq = queue;
-       struct sfc_txq *txq = sfc_txq_by_dp_txq(dp_txq);
+       const struct sfc_dp_tx *dp_tx;
 
-       return txq->evq->sa->priv.dp_tx->qdesc_status(dp_txq, offset);
+       dp_tx = sfc_dp_tx_by_dp_txq(dp_txq);
+
+       return dp_tx->qdesc_status(dp_txq, offset);
 }
 
 static int
@@ -1190,7 +1196,7 @@ sfc_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
        if (sa->state != SFC_ADAPTER_STARTED)
                goto fail_not_started;
 
-       if (sa->rxq_info[rx_queue_id].rxq == NULL)
+       if (sa->rxq_info[rx_queue_id].state != SFC_RXQ_INITIALIZED)
                goto fail_not_setup;
 
        rc = sfc_rx_qstart(sa, rx_queue_id);
@@ -1242,7 +1248,7 @@ sfc_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
        if (sa->state != SFC_ADAPTER_STARTED)
                goto fail_not_started;
 
-       if (sa->txq_info[tx_queue_id].txq == NULL)
+       if (sa->txq_info[tx_queue_id].state != SFC_TXQ_INITIALIZED)
                goto fail_not_setup;
 
        rc = sfc_tx_qstart(sa, tx_queue_id);
@@ -1397,6 +1403,10 @@ sfc_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
        return sfc_dev_udp_tunnel_op(dev, tunnel_udp, SFC_UDP_TUNNEL_DEL_PORT);
 }
 
+/*
+ * The function is used by the secondary process as well. It must not
+ * use any process-local pointers from the adapter data.
+ */
 static int
 sfc_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
                          struct rte_eth_rss_conf *rss_conf)
@@ -1497,6 +1507,10 @@ fail_rx_hf_rte_to_efx:
        return -rc;
 }
 
+/*
+ * The function is used by the secondary process as well. It must not
+ * use any process-local pointers from the adapter data.
+ */
 static int
 sfc_dev_rss_reta_query(struct rte_eth_dev *dev,
                       struct rte_eth_rss_reta_entry64 *reta_conf,
@@ -1896,6 +1910,9 @@ static const struct eth_dev_ops sfc_eth_dev_secondary_ops = {
        .rx_queue_count                 = sfc_rx_queue_count,
        .rx_descriptor_done             = sfc_rx_descriptor_done,
        .rx_descriptor_status           = sfc_rx_descriptor_status,
+       .tx_descriptor_status           = sfc_tx_descriptor_status,
+       .reta_query                     = sfc_dev_rss_reta_query,
+       .rss_hash_conf_get              = sfc_dev_rss_hash_conf_get,
        .rxq_info_get                   = sfc_rx_queue_info_get,
        .txq_info_get                   = sfc_tx_queue_info_get,
 };
@@ -2006,6 +2023,7 @@ static int
 sfc_eth_dev_init(struct rte_eth_dev *dev)
 {
        struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_adapter_shared *sas;
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
        uint32_t logtype_main;
        int rc;
@@ -2018,6 +2036,9 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
                                            SFC_LOGTYPE_MAIN_STR,
                                            RTE_LOG_NOTICE);
 
+       sa->priv.shared = &sa->_shared;
+       sas = sa->priv.shared;
+
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return -sfc_eth_dev_secondary_init(dev, logtype_main);
 
@@ -2030,8 +2051,8 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
        dev->process_private = sa;
 
        /* Required for logging */
-       sa->pci_addr = pci_dev->addr;
-       sa->port_id = dev->data->port_id;
+       sas->pci_addr = pci_dev->addr;
+       sas->port_id = dev->data->port_id;
        sa->priv.logtype_main = logtype_main;
 
        sa->eth_dev = dev;