ethdev: rename memzones allocated for DMA
[dpdk.git] / lib / librte_ethdev / rte_ethdev.c
index 3f8de93..571f0e8 100644 (file)
@@ -122,11 +122,12 @@ static const struct {
        RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
        RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
        RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
-       RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
        RTE_RX_OFFLOAD_BIT2STR(SCATTER),
        RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
        RTE_RX_OFFLOAD_BIT2STR(SECURITY),
        RTE_RX_OFFLOAD_BIT2STR(KEEP_CRC),
+       RTE_RX_OFFLOAD_BIT2STR(SCTP_CKSUM),
+       RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
 };
 
 #undef RTE_RX_OFFLOAD_BIT2STR
@@ -156,6 +157,9 @@ static const struct {
        RTE_TX_OFFLOAD_BIT2STR(MULTI_SEGS),
        RTE_TX_OFFLOAD_BIT2STR(MBUF_FAST_FREE),
        RTE_TX_OFFLOAD_BIT2STR(SECURITY),
+       RTE_TX_OFFLOAD_BIT2STR(UDP_TNL_TSO),
+       RTE_TX_OFFLOAD_BIT2STR(IP_TNL_TSO),
+       RTE_TX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
 };
 
 #undef RTE_TX_OFFLOAD_BIT2STR
@@ -358,6 +362,18 @@ rte_eth_dev_attach_secondary(const char *name)
        return eth_dev;
 }
 
+int
+rte_eth_dev_release_port_secondary(struct rte_eth_dev *eth_dev)
+{
+       if (eth_dev == NULL)
+               return -EINVAL;
+
+       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+       eth_dev->state = RTE_ETH_DEV_UNUSED;
+
+       return 0;
+}
+
 int
 rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 {
@@ -1147,14 +1163,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
                return -EINVAL;
        }
 
-       if ((local_conf.rxmode.offloads & DEV_RX_OFFLOAD_CRC_STRIP) &&
-                       (local_conf.rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC)) {
-               RTE_ETHDEV_LOG(ERR,
-                       "Port id=%u not allowed to set both CRC STRIP and KEEP CRC offload flags\n",
-                       port_id);
-               return -EINVAL;
-       }
-
        /* Check that device supports requested rss hash functions. */
        if ((dev_info.flow_type_rss_offloads |
             dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
@@ -3440,6 +3448,43 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
        return 0;
 }
 
+int __rte_experimental
+rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id)
+{
+       struct rte_intr_handle *intr_handle;
+       struct rte_eth_dev *dev;
+       unsigned int efd_idx;
+       uint32_t vec;
+       int fd;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
+
+       dev = &rte_eth_devices[port_id];
+
+       if (queue_id >= dev->data->nb_rx_queues) {
+               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
+               return -1;
+       }
+
+       if (!dev->intr_handle) {
+               RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
+               return -1;
+       }
+
+       intr_handle = dev->intr_handle;
+       if (!intr_handle->intr_vec) {
+               RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+               return -1;
+       }
+
+       vec = intr_handle->intr_vec[queue_id];
+       efd_idx = (vec >= RTE_INTR_VEC_RXTX_OFFSET) ?
+               (vec - RTE_INTR_VEC_RXTX_OFFSET) : vec;
+       fd = intr_handle->efds[efd_idx];
+
+       return fd;
+}
+
 const struct rte_memzone *
 rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
                         uint16_t queue_id, size_t size, unsigned align,
@@ -3448,9 +3493,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
        char z_name[RTE_MEMZONE_NAMESIZE];
        const struct rte_memzone *mz;
 
-       snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                dev->device->driver->name, ring_name,
-                dev->data->port_id, queue_id);
+       snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+                dev->data->port_id, queue_id, ring_name);
 
        mz = rte_memzone_lookup(z_name);
        if (mz)
@@ -3474,10 +3518,8 @@ rte_eth_dev_create(struct rte_device *device, const char *name,
 
        if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
                ethdev = rte_eth_dev_allocate(name);
-               if (!ethdev) {
-                       retval = -ENODEV;
-                       goto probe_failed;
-               }
+               if (!ethdev)
+                       return -ENODEV;
 
                if (priv_data_size) {
                        ethdev->data->dev_private = rte_zmalloc_socket(
@@ -3487,7 +3529,7 @@ rte_eth_dev_create(struct rte_device *device, const char *name,
                        if (!ethdev->data->dev_private) {
                                RTE_LOG(ERR, EAL, "failed to allocate private data");
                                retval = -ENOMEM;
-                               goto probe_failed;
+                               goto data_alloc_failed;
                        }
                }
        } else {
@@ -3495,8 +3537,7 @@ rte_eth_dev_create(struct rte_device *device, const char *name,
                if (!ethdev) {
                        RTE_LOG(ERR, EAL, "secondary process attach failed, "
                                "ethdev doesn't exist");
-                       retval = -ENODEV;
-                       goto probe_failed;
+                       return  -ENODEV;
                }
        }
 
@@ -3525,6 +3566,7 @@ probe_failed:
        if (rte_eal_process_type() == RTE_PROC_PRIMARY)
                rte_free(ethdev->data->dev_private);
 
+data_alloc_failed:
        rte_eth_dev_release_port(ethdev);
 
        return retval;
@@ -3547,9 +3589,10 @@ rte_eth_dev_destroy(struct rte_eth_dev *ethdev,
                        return ret;
        }
 
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-               rte_free(ethdev->data->dev_private);
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return rte_eth_dev_release_port_secondary(ethdev);
 
+       rte_free(ethdev->data->dev_private);
        ethdev->data->dev_private = NULL;
 
        return rte_eth_dev_release_port(ethdev);