ethdev: new Rx/Tx offloads API
[dpdk.git] / drivers / net / mvpp2 / mrvl_ethdev.c
index 6ab515c..c9d85ca 100644 (file)
@@ -318,26 +318,11 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
                dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
        }
 
-       if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_VLAN_STRIP) {
-               RTE_LOG(INFO, PMD, "VLAN stripping not supported\n");
-               return -EINVAL;
-       }
-
        if (dev->data->dev_conf.rxmode.split_hdr_size) {
                RTE_LOG(INFO, PMD, "Split headers not supported\n");
                return -EINVAL;
        }
 
-       if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_SCATTER) {
-               RTE_LOG(INFO, PMD, "RX Scatter/Gather not supported\n");
-               return -EINVAL;
-       }
-
-       if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
-               RTE_LOG(INFO, PMD, "LRO not supported\n");
-               return -EINVAL;
-       }
-
        if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
                dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
                                 ETHER_HDR_LEN - ETHER_CRC_LEN;
@@ -1061,18 +1046,21 @@ mrvl_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
  *   Pointer to Ethernet device structure.
  * @param mac_addr
  *   MAC address to register.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
  */
-static void
+static int
 mrvl_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
        if (!priv->ppio)
-               return;
+               return 0;
 
        if (priv->isolated)
-               return;
+               return -ENOTSUP;
 
        ret = pp2_ppio_set_mac_addr(priv->ppio, mac_addr->addr_bytes);
        if (ret) {
@@ -1080,6 +1068,8 @@ mrvl_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
                ether_format_addr(buf, sizeof(buf), mac_addr);
                RTE_LOG(ERR, PMD, "Failed to set mac to %s\n", buf);
        }
+
+       return ret;
 }
 
 /**
@@ -1516,42 +1506,6 @@ out:
        return -1;
 }
 
-/**
- * Check whether requested rx queue offloads match port offloads.
- *
- * @param
- *   dev Pointer to the device.
- * @param
- *   requested Bitmap of the requested offloads.
- *
- * @return
- *   1 if requested offloads are okay, 0 otherwise.
- */
-static int
-mrvl_rx_queue_offloads_okay(struct rte_eth_dev *dev, uint64_t requested)
-{
-       uint64_t mandatory = dev->data->dev_conf.rxmode.offloads;
-       uint64_t supported = MRVL_RX_OFFLOADS;
-       uint64_t unsupported = requested & ~supported;
-       uint64_t missing = mandatory & ~requested;
-
-       if (unsupported) {
-               RTE_LOG(ERR, PMD, "Some Rx offloads are not supported. "
-                       "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n",
-                       requested, supported);
-               return 0;
-       }
-
-       if (missing) {
-               RTE_LOG(ERR, PMD, "Some Rx offloads are missing. "
-                       "Requested 0x%" PRIx64 " missing 0x%" PRIx64 ".\n",
-                       requested, missing);
-               return 0;
-       }
-
-       return 1;
-}
-
 /**
  * DPDK callback to configure the receive queue.
  *
@@ -1582,9 +1536,9 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
        uint32_t min_size,
                 max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
        int ret, tc, inq;
+       uint64_t offloads;
 
-       if (!mrvl_rx_queue_offloads_okay(dev, conf->offloads))
-               return -ENOTSUP;
+       offloads = conf->offloads | dev->data->dev_conf.rxmode.offloads;
 
        if (priv->rxq_map[idx].tc == MRVL_UNKNOWN_TC) {
                /*
@@ -1617,8 +1571,7 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 
        rxq->priv = priv;
        rxq->mp = mp;
-       rxq->cksum_enabled =
-               dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_IPV4_CKSUM;
+       rxq->cksum_enabled = offloads & DEV_RX_OFFLOAD_IPV4_CKSUM;
        rxq->queue_id = idx;
        rxq->port_id = dev->data->port_id;
        mrvl_port_to_bpool_lookup[rxq->port_id] = priv->bpool;
@@ -1680,42 +1633,6 @@ mrvl_rx_queue_release(void *rxq)
        rte_free(q);
 }
 
-/**
- * Check whether requested tx queue offloads match port offloads.
- *
- * @param
- *   dev Pointer to the device.
- * @param
- *   requested Bitmap of the requested offloads.
- *
- * @return
- *   1 if requested offloads are okay, 0 otherwise.
- */
-static int
-mrvl_tx_queue_offloads_okay(struct rte_eth_dev *dev, uint64_t requested)
-{
-       uint64_t mandatory = dev->data->dev_conf.txmode.offloads;
-       uint64_t supported = MRVL_TX_OFFLOADS;
-       uint64_t unsupported = requested & ~supported;
-       uint64_t missing = mandatory & ~requested;
-
-       if (unsupported) {
-               RTE_LOG(ERR, PMD, "Some Tx offloads are not supported. "
-                       "Requested 0x%" PRIx64 " supported 0x%" PRIx64 ".\n",
-                       requested, supported);
-               return 0;
-       }
-
-       if (missing) {
-               RTE_LOG(ERR, PMD, "Some Tx offloads are missing. "
-                       "Requested 0x%" PRIx64 " missing 0x%" PRIx64 ".\n",
-                       requested, missing);
-               return 0;
-       }
-
-       return 1;
-}
-
 /**
  * DPDK callback to configure the transmit queue.
  *
@@ -1741,9 +1658,6 @@ mrvl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
        struct mrvl_priv *priv = dev->data->dev_private;
        struct mrvl_txq *txq;
 
-       if (!mrvl_tx_queue_offloads_okay(dev, conf->offloads))
-               return -ENOTSUP;
-
        if (dev->data->tx_queues[idx]) {
                rte_free(dev->data->tx_queues[idx]);
                dev->data->tx_queues[idx] = NULL;
@@ -2805,7 +2719,7 @@ rte_pmd_mrvl_remove(struct rte_vdev_device *vdev)
 
        RTE_LOG(INFO, PMD, "Removing %s\n", name);
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) { /* FIXME: removing all devices! */
                char ifname[RTE_ETH_NAME_MAX_LEN];
 
                rte_eth_dev_get_name_by_port(i, ifname);