ethdev: add new offload flag to keep CRC
[dpdk.git] / drivers / net / octeontx / octeontx_ethdev.c
index 6d67d25..6eb6836 100644 (file)
@@ -262,8 +262,6 @@ octeontx_dev_configure(struct rte_eth_dev *dev)
        struct rte_eth_rxmode *rxmode = &conf->rxmode;
        struct rte_eth_txmode *txmode = &conf->txmode;
        struct octeontx_nic *nic = octeontx_pmd_priv(dev);
-       uint64_t configured_offloads;
-       uint64_t unsupported_offloads;
        int ret;
 
        PMD_INIT_FUNC_TRACE();
@@ -285,38 +283,17 @@ octeontx_dev_configure(struct rte_eth_dev *dev)
                return -EINVAL;
        }
 
-       configured_offloads = rxmode->offloads;
-
-       if (!(configured_offloads & DEV_RX_OFFLOAD_CRC_STRIP)) {
+       /* KEEP_CRC offload flag is not supported by PMD
+        * can remove the below block when DEV_RX_OFFLOAD_CRC_STRIP removed
+        */
+       if (rte_eth_dev_must_keep_crc(rxmode->offloads)) {
                PMD_INIT_LOG(NOTICE, "can't disable hw crc strip");
-               configured_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
+               rxmode->offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
        }
 
-       unsupported_offloads = configured_offloads & ~OCTEONTX_RX_OFFLOADS;
-
-       if (unsupported_offloads) {
-               PMD_INIT_LOG(ERR, "Rx offloads 0x%" PRIx64 " are not supported. "
-                     "Requested 0x%" PRIx64 " supported 0x%" PRIx64 "\n",
-                     unsupported_offloads, configured_offloads,
-                     (uint64_t)OCTEONTX_RX_OFFLOADS);
-               return -ENOTSUP;
-       }
-
-       configured_offloads = txmode->offloads;
-
-       if (!(configured_offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) {
+       if (!(txmode->offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) {
                PMD_INIT_LOG(NOTICE, "cant disable lockfree tx");
-               configured_offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE;
-       }
-
-       unsupported_offloads = configured_offloads & ~OCTEONTX_TX_OFFLOADS;
-
-       if (unsupported_offloads) {
-               PMD_INIT_LOG(ERR, "Tx offloads 0x%" PRIx64 " are not supported."
-                     "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n",
-                     unsupported_offloads, configured_offloads,
-                     (uint64_t)OCTEONTX_TX_OFFLOADS);
-               return -ENOTSUP;
+               txmode->offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE;
        }
 
        if (conf->link_speeds & ETH_LINK_SPEED_FIXED) {
@@ -627,10 +604,7 @@ octeontx_dev_info(struct rte_eth_dev *dev,
 
        dev_info->default_txconf = (struct rte_eth_txconf) {
                .tx_free_thresh = 0,
-               .txq_flags =
-                       ETH_TXQ_FLAGS_NOMULTSEGS |
-                       ETH_TXQ_FLAGS_NOOFFLOADS |
-                       ETH_TXQ_FLAGS_NOXSUMS,
+               .offloads = OCTEONTX_TX_OFFLOADS,
        };
 
        dev_info->rx_offload_capa = OCTEONTX_RX_OFFLOADS;
@@ -738,14 +712,12 @@ octeontx_dev_tx_queue_release(void *tx_queue)
 static int
 octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
                            uint16_t nb_desc, unsigned int socket_id,
-                           const struct rte_eth_txconf *tx_conf)
+                           const struct rte_eth_txconf *tx_conf __rte_unused)
 {
        struct octeontx_nic *nic = octeontx_pmd_priv(dev);
        struct octeontx_txq *txq = NULL;
        uint16_t dq_num;
        int res = 0;
-       uint64_t configured_offloads;
-       uint64_t unsupported_offloads;
 
        RTE_SET_USED(nb_desc);
        RTE_SET_USED(socket_id);
@@ -766,22 +738,6 @@ octeontx_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
                dev->data->tx_queues[qidx] = NULL;
        }
 
-       configured_offloads = tx_conf->offloads;
-
-       if (!(configured_offloads & DEV_TX_OFFLOAD_MT_LOCKFREE)) {
-               PMD_INIT_LOG(NOTICE, "cant disable lockfree tx");
-               configured_offloads |= DEV_TX_OFFLOAD_MT_LOCKFREE;
-       }
-
-       unsupported_offloads = configured_offloads & ~OCTEONTX_TX_OFFLOADS;
-       if (unsupported_offloads) {
-               PMD_INIT_LOG(ERR, "Tx offloads 0x%" PRIx64 " are not supported."
-                     "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n",
-                     unsupported_offloads, configured_offloads,
-                     (uint64_t)OCTEONTX_TX_OFFLOADS);
-               return -ENOTSUP;
-       }
-
        /* Allocating tx queue data structure */
        txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct octeontx_txq),
                                 RTE_CACHE_LINE_SIZE, nic->node);
@@ -837,8 +793,6 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
        uint8_t gaura;
        unsigned int ev_queues = (nic->ev_queues * nic->port_id) + qidx;
        unsigned int ev_ports = (nic->ev_ports * nic->port_id) + qidx;
-       uint64_t configured_offloads;
-       uint64_t unsupported_offloads;
 
        RTE_SET_USED(nb_desc);
 
@@ -861,22 +815,6 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 
        port = nic->port_id;
 
-       configured_offloads = rx_conf->offloads;
-
-       if (!(configured_offloads & DEV_RX_OFFLOAD_CRC_STRIP)) {
-               PMD_INIT_LOG(NOTICE, "can't disable hw crc strip");
-               configured_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
-       }
-
-       unsupported_offloads = configured_offloads & ~OCTEONTX_RX_OFFLOADS;
-
-       if (unsupported_offloads) {
-               PMD_INIT_LOG(ERR, "Rx offloads 0x%" PRIx64 " are not supported. "
-                     "Requested 0x%" PRIx64 " supported 0x%" PRIx64 "\n",
-                     unsupported_offloads, configured_offloads,
-                     (uint64_t)OCTEONTX_RX_OFFLOADS);
-               return -ENOTSUP;
-       }
        /* Rx deferred start is not supported */
        if (rx_conf->rx_deferred_start) {
                octeontx_log_err("rx deferred start not supported");
@@ -1068,7 +1006,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
        char octtx_name[OCTEONTX_MAX_NAME_LEN];
        struct octeontx_nic *nic = NULL;
        struct rte_eth_dev *eth_dev = NULL;
-       struct rte_eth_dev_data *data = NULL;
+       struct rte_eth_dev_data *data;
        const char *name = rte_vdev_device_name(dev);
 
        PMD_INIT_FUNC_TRACE();
@@ -1081,16 +1019,10 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 
                eth_dev->tx_pkt_burst = octeontx_xmit_pkts;
                eth_dev->rx_pkt_burst = octeontx_recv_pkts;
+               rte_eth_dev_probing_finish(eth_dev);
                return 0;
        }
 
-       data = rte_zmalloc_socket(octtx_name, sizeof(*data), 0, socket_id);
-       if (data == NULL) {
-               octeontx_log_err("failed to allocate devdata");
-               res = -ENOMEM;
-               goto err;
-       }
-
        nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id);
        if (nic == NULL) {
                octeontx_log_err("failed to allocate nic structure");
@@ -1126,11 +1058,9 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
        eth_dev->data->kdrv = RTE_KDRV_NONE;
        eth_dev->data->numa_node = dev->device.numa_node;
 
-       rte_memcpy(data, (eth_dev)->data, sizeof(*data));
+       data = eth_dev->data;
        data->dev_private = nic;
-
        data->port_id = eth_dev->data->port_id;
-       snprintf(data->name, sizeof(data->name), "%s", eth_dev->data->name);
 
        nic->ev_queues = 1;
        nic->ev_ports = 1;
@@ -1149,7 +1079,6 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
                goto err;
        }
 
-       eth_dev->data = data;
        eth_dev->dev_ops = &octeontx_dev_ops;
 
        /* Finally save ethdev pointer to the NIC structure */
@@ -1175,6 +1104,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
        rte_octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7]
                [(nic->base_ochan >> 4) & 0xF] = data->port_id;
 
+       rte_eth_dev_probing_finish(eth_dev);
        return data->port_id;
 
 err:
@@ -1217,7 +1147,6 @@ octeontx_remove(struct rte_vdev_device *dev)
 
                rte_free(eth_dev->data->mac_addrs);
                rte_free(eth_dev->data->dev_private);
-               rte_free(eth_dev->data);
                rte_eth_dev_release_port(eth_dev);
                rte_event_dev_close(nic->evdev);
        }
@@ -1239,12 +1168,27 @@ octeontx_probe(struct rte_vdev_device *dev)
        struct rte_event_dev_config dev_conf;
        const char *eventdev_name = "event_octeontx";
        struct rte_event_dev_info info;
+       struct rte_eth_dev *eth_dev;
 
        struct octeontx_vdev_init_params init_params = {
                OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT
        };
 
        dev_name = rte_vdev_device_name(dev);
+
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+           strlen(rte_vdev_device_args(dev)) == 0) {
+               eth_dev = rte_eth_dev_attach_secondary(dev_name);
+               if (!eth_dev) {
+                       RTE_LOG(ERR, PMD, "Failed to probe %s\n", dev_name);
+                       return -1;
+               }
+               /* TODO: request info from primary to set up Rx and Tx */
+               eth_dev->dev_ops = &octeontx_dev_ops;
+               rte_eth_dev_probing_finish(eth_dev);
+               return 0;
+       }
+
        res = octeontx_parse_vdev_init_params(&init_params, dev);
        if (res < 0)
                return -EINVAL;